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