Author Topic: What is difference between ...?  (Read 1476 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
What is difference between ...?
« 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 ... )
     )
?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: What is difference between ...?
« Reply #1 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.
« Last Edit: May 27, 2012, 09:10:17 AM by gile »
Speaking English as a French Frog

pBe

  • Bull Frog
  • Posts: 402
Re: What is difference between ...?
« Reply #2 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

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: What is difference between ...?
« Reply #3 on: May 27, 2012, 09:43:52 AM »
I got it

gile Thanks
pBe Thanks