Mercurial > hg > octave-nkf
annotate scripts/general/strerror.m @ 11469:c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 12:41:21 -0800 |
parents | a1dbe9d80eee |
children | 1740012184f9 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1995, 1996, 1997, 1999, 2002, 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/>. | |
1576 | 19 |
3381 | 20 ## -*- texinfo -*- |
3373 | 21 ## @deftypefn {Function File} {} strerror (@var{name}, @var{num}) |
22 ## Return the text of an error message for function @var{name} | |
23 ## corresponding to the error number @var{num}. This function is intended | |
24 ## to be used to print useful error messages for those functions that | |
25 ## return numeric error codes. | |
26 ## @end deftypefn | |
1576 | 27 |
2314 | 28 ## Author: jwe |
29 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
30 function msg = strerror (name, num) |
1576 | 31 |
32 if (nargin != 2) | |
6046 | 33 print_usage (); |
1576 | 34 endif |
35 | |
5443 | 36 if (! ischar (name)) |
1576 | 37 error ("strerror: first argument must be a string"); |
38 endif | |
39 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
40 if (! isscalar (num)) |
1576 | 41 error ("strerror: second argument must be a scalar"); |
42 endif | |
43 | |
44 if (strcmp (name, "fsolve")) | |
45 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
46 if (num == -2) |
1576 | 47 msg = "input error\n"; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
48 elseif (num == -1) |
1576 | 49 msg = "error encountered in user-supplied function\n"; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
50 elseif (num == 1) |
1576 | 51 msg = "solution converged to requested tolerance\n"; |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
52 elseif (num == 3) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
53 msg = "iteration is not making good progress\n"; |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
54 elseif (num == 4) |
1576 | 55 msg = "iteration limit exceeded\n"; |
56 else | |
57 error ("strerror: unrecognized error code for fsolve"); | |
58 endif | |
59 | |
60 else | |
61 | |
62 error ("strerror: unrecognized function name"); | |
63 | |
64 endif | |
65 | |
66 endfunction |