TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on May 27, 2012, 08:30:44 AM

Title: What is difference between ...?
Post by: HasanCAD on May 27, 2012, 08:30:44 AM
What is difference between ...

Code: [Select]
(and (setq p1 ... )
     (setq p2 ... )
     (setq p3 ... )
     (setq p4 ... )
     )
And
Code: [Select]
(and (setq p1 ...
   p2 ...
   p3 ...
   p4 ... )
     )
?
Title: Re: What is difference between ...?
Post by: gile on May 27, 2012, 08:52:29 AM
(and (setq p1 ... )
     (setq p2 ... )
     (setq p3 ... )
     (setq p4 ... )
     )
returns T if none of p1 p2 p3 p4 is nil and stops the evaluation when the first nil is reached.

(and (setq p1 ...
      p2 ...
      p3 ...
      p4 ... )
     )
returns T if p4 is not nil.
Title: Re: What is difference between ...?
Post by: pBe on May 27, 2012, 09:34:35 AM
Also consider this:
Code - Auto/Visual Lisp: [Select]
  1. (and (setq a (car (entsel)))
  2.      (setq b (entget a)))
  3.  

Code - Auto/Visual Lisp: [Select]
  1. (and (setq a (car (entsel))
  2.            b (entget a)))

In the event the first expression evaluates to nil the first code will terminate without evaluating the second expression, while the 2nd code will still continue even if the frist expression results to nil and it will generate an error.

HTH
Title: Re: What is difference between ...?
Post by: HasanCAD on May 27, 2012, 09:43:52 AM
I got it

gile Thanks
pBe Thanks