LISP Tip : When using IF and PROGN

Topics relating to AutoLisp and SDS.

Moderators: CMS Inc, avaernes

Post Reply
UberEber
Contributor
Posts: 21
Joined: Fri Mar 22, 2019 1:57 am

LISP Tip : When using IF and PROGN

Post by UberEber » Sun May 05, 2019 7:27 am

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!
Post Reply