2 newerror - create or recall a described error-value
13 If str is not "" and has not earlier been used as an argument for
14 this function, newerror(str) creates a new described error-value so
15 that any future use of newerror(str) with the same str will return
18 If x = newerror(str), both strerror(x) and strerror(iserro(x)) will
19 return str and iserror(x) will return the error code value of the
22 The null cases newerror() and newerror("") are equivalent to
26 Note that by default, errmax() is 0 so unless errmax() is
27 increased you will get:
29 ; ba = newerror("curds n' whey");
30 Error 20000 caused errcount to exceed errmax
32 ; errmax(errcount()+5)
34 ; e1 = newerror("triangle side length <= 0")
39 ; strerror(error(20000))
40 "triangle side length <= 0"
42 "triangle side length <= 0"
43 ; strerror(error(iserror(e1)))
44 "triangle side length <= 0"
46 ; define area(a,b,c) {
48 ;; if (!(a > 0) || !(b > 0) || !(c > 0)) return e1;
50 ;; if (s <= a || s <= b || s <= c) return newerror("Non-triangle sides");
51 ;; return sqrt(s * (s - a) * (s - b) * (s - c));
56 ; if (iserror(A)) print strerror(A) : ":", iserror(A);
57 Non-triangle sides: 20001
60 ; if (iserror(A)) print strerror(A) : ":", iserror(A);
61 triangle side length <= 0: 20000
64 The number of new described error-values is not to exceed 12767.
70 errmax, errcount, error, strerror, iserror, errno, errorcodes,
73 ## Copyright (C) 1999-2006 Landon Curt Noll
75 ## Calc is open software; you can redistribute it and/or modify it under
76 ## the terms of the version 2.1 of the GNU Lesser General Public License
77 ## as published by the Free Software Foundation.
79 ## Calc is distributed in the hope that it will be useful, but WITHOUT
80 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
81 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
82 ## Public License for more details.
84 ## A copy of version 2.1 of the GNU Lesser General Public License is
85 ## distributed with calc under the filename COPYING-LGPL. You should have
86 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
87 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
89 ## @(#) $Revision: 30.1 $
90 ## @(#) $Id: newerror,v 30.1 2007/03/16 11:10:42 chongo Exp $
91 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/newerror,v $
93 ## Under source code control: 1996/04/30 03:39:56
94 ## File existed as early as: 1996
96 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
97 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/