Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please someone explain an IF ELSE statement if LISP.. 1

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi,

Could someone please explain a typical IF ELSE statement in AutoLISP..

I've checked the help and it suggest the PROGN fucntion and i can't quite get my head round it, lol. Excuse me if i'm being hella-stupid..

Basically, i want to create a simple command line based routine that allows me to switch point styles. I want to just type something like PP, and it switches point style between the small dot (0 in PDMODE) and the crossed circle (35 in PDMODE)..
So if the point style is 35, then switch it to 1, and vice versa..



Cheers,
Paul @ basepoint designz ltd..

basepointdesignzltd
 
The reason the help files suggest the PROGN function is as follows...

Basic If statement
Code:
(IF (single statement that will return TRUE or FALSE)
    (single statement that will be evaluated if above is TRUE)
    (single statement that will be evaluated if above is FALSE)
);end of IF

The statements evaluated by the IF statment are single statemnts only. If you require more complex locig to be evaluated you need to have it look like...

Code:
(IF (single statement that will return TRUE or FALSE)
    (PROGN
       (statements that)
       (will be evaluated)
       (if above is TRUE)
    )
    (PROGN
       (statements that will)
       (be evaluated if above is FALSE)
    )
);end of IF

The PROGN function is used to make the LISP compiler behave as if everything with in the (PROGN .....) is a single statement.

I hope this is clear.

Kevin Petursson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top