Mercurial > hg > octave-nkf
annotate scripts/general/nargchk.m @ 7671:4fbaba9abec1
implement compiled binary lookup
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 28 Mar 2008 15:53:09 -0400 |
parents | 1ce6460aebdf |
children | d65b33e55d40 |
rev | line source |
---|---|
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. | |
7658
1ce6460aebdf
nargoutchk.m, validatestring.m, addtodate.m: new functions
bill@denney.ws
parents:
7017
diff
changeset
|
28 ## @seealso{nargoutchk, error, nargin, nargout} |
3371 | 29 ## @end deftypefn |
710 | 30 |
2314 | 31 ## Author: jwe |
32 | |
2311 | 33 function retval = nargchk (nargin_min, nargin_max, n) |
710 | 34 |
35 if (nargin != 3) | |
6046 | 36 print_usage (); |
710 | 37 endif |
38 | |
39 if (nargin_min > nargin_max) | |
7658
1ce6460aebdf
nargoutchk.m, validatestring.m, addtodate.m: new functions
bill@denney.ws
parents:
7017
diff
changeset
|
40 error ("nargchk: nargin_min > nargin_max"); |
710 | 41 endif |
42 | |
43 if (n < nargin_min) | |
44 retval = "nargchk: N is less than nargin_min"; | |
45 elseif (n > nargin_max) | |
46 retval = "nargchk: N is greater than nargin_max"; | |
47 else | |
48 retval = []; | |
49 endif | |
50 | |
51 endfunction |