Post Reply 
How to check for and trap a CAS error in a program?
12-02-2018, 02:25 AM (This post was last modified: 12-02-2018 02:25 AM by Jacob Wall.)
Post: #6
RE: How to check for and trap a CAS error in a program?
One thing to remember, if you have a PPL program with an IFERR statement, there is an excellent chance that the next CAS command you use will crash your program.

Example:
Code:
EXPORT Demo_IFERR()
BEGIN
  LOCAL m;
  RECT_P();
  TEXTOUT_P("Press ON to generate an error ...",G0,5,5,4);
  REPEAT  
    IFERR m:=WAIT(-1); THEN
      m:=4;
      TEXTOUT_P("Error triggered ...",G0,5,25,4);
    ELSE
      TEXTOUT_P("Error avoided ...",G0,5,25,4);
    END;
  UNTIL TYPE(m)==0;
  TEXTOUT_P("Program still running ...",G0,5,45,4);
  WAIT(1);
  MSGBOX(stddev({0.01,0.02,-0.015,0.005}));
END;

You can force the error in the program above by pressing the ON key on the keyboard. If you do so, the crash/error happens when the "stddev" command is encountered. This is true for all CAS commands. Has caught me a few times now, and difficult to debug if you're not aware of this. I have written multiple substitute routines to get around the need for CAS commands as a result.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How to check for and trap a CAS error in a program? - Jacob Wall - 12-02-2018 02:25 AM



User(s) browsing this thread: 1 Guest(s)