7017
|
1 ## Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2005, 2006, 2007 |
|
2 ## John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
710
|
19 |
3371
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} nargchk (@var{nargin_min}, @var{nargin_max}, @var{n}) |
|
22 ## If @var{n} is in the range @var{nargin_min} through @var{nargin_max} |
|
23 ## inclusive, return the empty matrix. Otherwise, return a message |
|
24 ## indicating whether @var{n} is too large or too small. |
3426
|
25 ## |
3371
|
26 ## This is useful for checking to see that the number of arguments supplied |
|
27 ## to a function is within an acceptable range. |
|
28 ## @end deftypefn |
710
|
29 |
2314
|
30 ## Author: jwe |
|
31 |
2311
|
32 function retval = nargchk (nargin_min, nargin_max, n) |
710
|
33 |
|
34 if (nargin != 3) |
6046
|
35 print_usage (); |
710
|
36 endif |
|
37 |
|
38 if (nargin_min > nargin_max) |
|
39 error ("nargchk: nargin_min > nargin_max"); |
|
40 endif |
|
41 |
|
42 if (n < nargin_min) |
|
43 retval = "nargchk: N is less than nargin_min"; |
|
44 elseif (n > nargin_max) |
|
45 retval = "nargchk: N is greater than nargin_max"; |
|
46 else |
|
47 retval = []; |
|
48 endif |
|
49 |
|
50 endfunction |