comparison scripts/deprecated/strerror.m @ 12574:89604fa96d2f

Deprecate perror, strerror functions.
author Rik <octave@nomad.inbox5.com>
date Mon, 04 Apr 2011 13:37:13 -0700
parents scripts/general/strerror.m@fd0a3ac60b0e
children 72c96de7a403
comparison
equal deleted inserted replaced
12573:232a90612254 12574:89604fa96d2f
1 ## Copyright (C) 1995-2011 John W. Eaton
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
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
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} strerror (@var{name}, @var{num})
21 ## Return the text of an error message for function @var{name}
22 ## corresponding to the error number @var{num}. This function is intended
23 ## to be used to print useful error messages for those functions that
24 ## return numeric error codes.
25 ## @end deftypefn
26
27 ## Author: jwe
28
29 function msg = strerror (name, num)
30
31 persistent warned = false;
32 if (! warned)
33 warned = true;
34 warning ("Octave:deprecated-function",
35 "strerror is obsolete and will be removed from a future version of Octave.");
36 endif
37
38 if (nargin != 2)
39 print_usage ();
40 endif
41
42 if (! ischar (name))
43 error ("strerror: first argument must be a string");
44 endif
45
46 if (! isscalar (num))
47 error ("strerror: second argument must be a scalar");
48 endif
49
50 if (strcmp (name, "fsolve"))
51
52 if (num == -2)
53 msg = "input error\n";
54 elseif (num == -1)
55 msg = "error encountered in user-supplied function\n";
56 elseif (num == 1)
57 msg = "solution converged to requested tolerance\n";
58 elseif (num == 3)
59 msg = "iteration is not making good progress\n";
60 elseif (num == 4)
61 msg = "iteration limit exceeded\n";
62 else
63 error ("strerror: unrecognized error code for fsolve");
64 endif
65
66 else
67
68 error ("strerror: unrecognized function NAME");
69
70 endif
71
72 endfunction