kill(all)$

maxima :programming :use errcatch in if instruction ,version 1.0
peter.vlasschaert@gmail.com,01/12/2022

w:errcatch (a:5,1:0,b:7);

s:errormsg();

s1:symbolp(s);

s2:[a,s,b,w];

rem : stop evaluation after error occur in a expression inside w.

see : if instruction, "below"
-----------------------------------

what about s
-----------------

w1:[s,atom(s),properties(s),listp(s),symbolp(s)];

values;

if s = value then print("true") else ("false");

if atom(s) =true then print("true") else ("false")$

if s =strings  then print("true") else ("false")$

info:s

listp(w);

Function: errcatch (expr_1, ..., expr_n)
Evaluates expr_1, ..., expr_n one by one and returns [expr_n] (a list) if no error occurs. 
If an error occurs in the evaluation of any argument, errcatch prevents the error from propagating and 
returns the empty list [] without evaluating any more arguments.

errcatch is useful in batch files where one suspects an error might occur which would terminate 
the batch if the error weren't caught.
·

errcatch in : "if -then-else" construction 
-----------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------

no evaluation
------------------

if errcatch(1=0) then print("test") else print("good");

no assignment:  result : if evaluation
------------------------------------------------

if errcatch(1=0)=[] then print("test") else print("good")$

if errcatch(1=0)≠[] then print("test") else print("good")$

assignment:  result "error message" then if evaluation
----------------------------------------------------------------------

if errcatch(1:0)≠[] then print("test") else print("good")$

if errcatch(1:0)=[] then print("test") else print("good")$

-----------------------------------------------------------------------------------------------------------------------------------