TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Hangman on September 28, 2010, 05:54:46 PM

Title: Checking a list ...
Post by: Hangman on September 28, 2010, 05:54:46 PM
Afternoon everyone,
I'm having a brain cramp and can't seem to get a simple return, so I'm coming to you guys.

I have the following:
Code: [Select]
(setq var-a '(1.1 2.2 3.3))
Quote
Command: !a
(0.0 1.1 2.2)

Now if I want to check var-a, I THOUGHT I would type the following:
Code: [Select]
(if (= var-a '(1.1 2.2 3.3))(ALERT "Yahoo"))What I get is
Quote
nil

How do I verify the value of var-a ?

Thanks.
Title: Re: Checking a list ...
Post by: T.Willey on September 28, 2010, 05:56:57 PM
Maybe try ' equal ' or ' eq ' or maybe even throw in a fuzz factor with one of them.
Title: Re: Checking a list ...
Post by: Lee Mac on September 28, 2010, 05:57:41 PM
Be careful with the various equality tests...

Code: [Select]

Command: (= '(1 2 3) '(1 2 3))
nil

Command: (eq '(1 2 3) '(1 2 3))
nil

Command: (equal '(1 2 3) '(1 2 3))
T

Similarly for enames:

Code: [Select]
Command: (setq e (car (entsel)))

Select object: <Entity name: 7ef03940>

Command: (setq f (car (entsel)))

Select object: <Entity name: 7ef03940>

Command: (= e f)
nil

Command: (eq e f)
T

Command: (equal e f)
T
Title: Re: Checking a list ...
Post by: Hangman on September 28, 2010, 06:03:59 PM
Ohh, ...
EQ & EQUAL

And Equal has the Fuzz factor, thanks Tim.

Thank you guys.  Sorry for the stupidity I'm portraying today.