Contents - Index

ERROR Procedure


The ERROR procedure can be used only within an internal function or procedure.  The ERROR procedure allows the user to halt calculations with an explanatory message if a value is out of range.  (The WARNING procedure differs from the ERROR procedure in that a warning message is placed in the message queue and calculations are allowed to continue.)  The Error procedure has the following format: 






   CALL ERROR('My error message XXXF1',X)




  CALL ERROR('My error message')


The error string contained within single quotes is optional.  If a string is provided, the variable X is optional. The string may be a string constant or a string variable.  In either case, the error message may be customized to appear on multiple lines by using '||' as the line break indicator.  The following example will display message on two lines"


S$='This is the first line||This is the second line'



X is the value of the parameter that initiates the error.  If an error message is not provided but a numerical value is provided, EES will generate the following error message when it executes the ERROR procedure.


Calculations have been halted because a parameter is out of range.  The value of the parameter is XXX in function YYY.


Here XXX is the parameter value provided to the Error function and YYY is the function or procedure name.


If an error string is provided, EES will display that string, inserting the value of X in place of the characters XXX.  If a formatting option, such as A3, F1 or E4 follows the XXX, as in the example above, the value of X will be accordingly formatted, otherwise a default format will be applied.  If no format is supplied, automatic format is assumed. 


If no error message or value is provided so that the call is CALL ERROR(''), EES will stop execution of the program with no error message.


Note: To insert a string, rather than a numerical value, use $ as the formatting option following the XXX, for example,


    CALL ERROR('My error string is XXX$',X$)



This ERROR procedure will most likely be used with an IF - THEN - ELSE  statement as in the following example.


     Function abc(X,Y)

       if (x<=0) then CALL ERROR(' X must be greater than 0.  A value of XXXE4 was supplied',X)






When this function is called, the following message will be displayed and calculations will stop:


X must be greater than 0.  A value of -3.000E0 was supplied.


(Note:  use a semicolon instead of a comma as the list separator when using the European numerical format).