REDERR INDEX

REDERR _ _ _ _ _ _ _ _ _ _ _ _ command

The rederr command allows you to print an error message from inside a procedure or a block statement. The calculation is gracefully terminated.

syntax:

rederr<message>

<message> is an error message, usually inside double quotation marks (a string).

examples:


procedure fac(n);
   if not (fixp(n) and n>=0)
     then  rederr "Choose nonneg. integer only"
    else for i := 0:n-1 product i+1;
 

  fac 


fac a; 

  	   ***** Choose nonneg. integer only 


fac 5; 

  120

The above procedure finds the factorial of its argument. If n is not a positive integer or 0, an error message is returned.

If your procedure is executed in a file, the usual error message is printed, followed by Cont? (Y or N), just as any other error does from a file. Although the procedure is gracefully terminated, any switch settings or variable assignments you made before the error occurred are not undone. If you need to clean up such items before exiting, use a group statement, with the rederr command as its last statement.