Page 1 of 1

LISP Tip : When using IF and PROGN

Posted: Sun May 05, 2019 7:27 am
by UberEber
When using IF and PROGN the following is NOT liked in IntelliCADcms ....
Who cares about the 10,000 dollar seat per year programs ...

(if
(= myString newInput)
(princ "myString has been set to newInput) ;do if true

(progn ;do if false
(princ "Have a great morning. \n")
(princ "Have a great afternoon - too. \n")
);end progn

); end if

the above can fail.


===================================================================
Use PROGN ...twice
although technically according to LISP syntax you do not have to.


(if
(= myString newInput)
(progn ;**** NEW PROGN not really needed *****
(princ "myString has been set to newInput) ;do if true
);end progn

(progn ;do if false
(princ "Have a great morning. \n")
(princ "Have a great afternoon - too. \n")
);end progn

); end if


Summary: Use two progn's in an IF statement - avoid just one.

Have a day!