In a nutshell, if you set some variable equal to some value, that variable now has a value. Seems simple enough. Here's something to try: type !blah at the command line, you should see a "nil" pop up (assuming you haven't set "blah" to anything). This is because that variable has no assigned value. If you then type:
- (setq blah "hello, world")
then type !blah, you'll see "hello, world" appear. This is because that variable now has a value.
When doing any sort of true/false check, like using a while loop, an if statement, or the and/or statements, you're checking not for a specific value, but overall, true or false (or, perhaps more specifically, true or nil).
So lets see that in action.
First, test this bit of code:
This should return nil. So if we then do this:
- (if varvar (princ "True") (princ "False"))
We know 'varvar' is nil, so we know we'll see "False" printed. Now lets do this:
And check that If statement again. It'll return "True", because varvar is true.
Now, try these:
- (setq varvar 1)(setq varvar 5.0)(setq varvar "variable")(setq varvar (list 1 2 3))
You'll see that as long as varvar has a value associated with it, the If statement will see it as 'true' and it will print "True".
That was your problem: you set a variable equal to something, gave it a defined value, and the checked to see if that value existed. It always exists. What you need to do is not check to see whether or not the list which defines your filter exists, but to see if your selection set has found anything.
Does that help to clear things up? |