mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.10.2t30
This commit is contained in:
39
help/newerror
Normal file
39
help/newerror
Normal file
@@ -0,0 +1,39 @@
|
||||
NAME
|
||||
newerror - create a new error type
|
||||
|
||||
SYNOPSIS
|
||||
newerror([str])
|
||||
|
||||
TYPES
|
||||
str non-null string
|
||||
|
||||
return error-value
|
||||
|
||||
DESCRIPTION
|
||||
With or without an argument, newerror() creates an error-value
|
||||
different from already existing error-values. With the argument
|
||||
str, if x == newerror(str), strerror(iserror(x)) returns str.
|
||||
|
||||
EXAMPLE
|
||||
> e1 = newerror("Non-positive side")
|
||||
> e2 = newerror("Non-triangle sides")
|
||||
|
||||
> define area(a,b,c) {\
|
||||
> local s;\
|
||||
> if (!(a > 0) || !(b > 0) || !(c > 0)) return e1;\
|
||||
> s = (a + b + c)/2;\
|
||||
> if (s <= a || s <= b || s <= c) return e2;\
|
||||
> return sqrt(s * (s - a) * (s - b) * (s - c)); }
|
||||
|
||||
> print strerror(iserror(area(8,2,5)))
|
||||
|
||||
Non-triangle sides
|
||||
|
||||
LIMITS
|
||||
none - XXX - is this correct?
|
||||
|
||||
LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
errorcodes, iserror, error
|
Reference in New Issue
Block a user