in the cond function, If something meets condition 1 and condition 2, does it fall under condition 1 then skip to the end of the cond function?
|
|
|
in the cond function, If something meets condition 1 and condition 2, does it fall under condition 1 then skip to the end of the cond function?
As far as I know, it will return on the first instance of the condition being true and not read any further possibilities.Originally Posted by ccowgill
Have you checked out the (cond) function in HELP (acad_dev.chm)?Originally Posted by ccowgill
The first "test" in the list that is non-nil will cause it's expressions to be evaluated, and the results are returned. No further evaluation of any more "test" will be done.
Example:
If sample.txt cannot be found, the (cond) returns the first (princ) statement and then ends.Code:(cond ( (not (setq fn (findfile "sample.txt"))) (princ "\nCannot find sample.txt")) ( (not (setq fh (open fn "r"))) (princ "\nCannot open sample.txt.")) (T (do_your_function_here)) )
If sample.txt is found, but cannot be opened, then the second (princ) statement is returned and the (cond) ends.
If both of the first two tests are nil (meaning that the file exists and it is opened successfully), then the last test (T) will always evaluate as "true" and the following expression will be executed.
Carl_hd_Collins was close, except that a statement doesn't have to be TRUE to execute, only non-nil.
Last edited by rkmcswain; 2006-11-16 at 02:33 PM.
R.K. McSwain | CAD Panacea |
That's all I needed to know, thanks.
Sorry, that was what I meant, my Lispese failed me!Originally Posted by rkmcswain
I figured so, but just wanted to clear it upOriginally Posted by carl_hd_collins
R.K. McSwain | CAD Panacea |
[ Moderator Action = ON ] Cab, I have merged your informative post into the Anatomy of an AUTOLISP file thread. You can find the location of your post here.
Thank you for your contribution.
Richard
Forum Moderator[ Moderator Action = OFF ]
Last edited by Opie; 2006-11-18 at 05:08 PM. Reason: See Moderator Action
Excellent information. Thanks.Originally Posted by CAB2k
R.K. McSwain | CAD Panacea |
No it can’t be too muchOriginally Posted by CAB2k
Hey CAB2k why not bring this great story and a to the bar desk in "Anatomy of an AUTOLISP file"
Welcome in . . .
: ) Happy Computing !
kennet
kennet, I'll see what I can do to get it moved. No need to double post.Originally Posted by kennet.sjoberg
If you have a technical question, please find the appropriate forum and ask it there.
You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
jUSt