Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unexpected result from "OR"

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
aesh
303 Views, 2 Replies

Unexpected result from "OR"

Has anyone run into this before?

 

I'm making a conditional statement for a list, but when I add the 'or' operator, it applies the action to all the values, not just the ones I called in the statement.

 

I'm starting with this and it works fine:

(start_list "a2")
  (cond
    ((= val "0")
    (add_list "1/8"))

    ((= val "1")
    (add_list "1/8"))

    ((= val "2")
    (add_list "1/8")(add_list "3/16")(add_list "1/4"))  etc...

  );cond
(end_list)

 but when I change it to this, it applies the first action to ALL the values and disregards the rest of the statement:

 

      (start_list "a2")
        (cond
          (or (= val "0")(= val "1")
          (add_list "1/8"))

          ((= val "2")
          (add_list "1/8")(add_list "3/16")(add_list "1/4"))  etc...
           
        );cond
      (end_list)

 

2 REPLIES 2
Message 2 of 3
dgorsman
in reply to: aesh

I think your test condition isn't wrapped correctly.  The brackets around the (or...) statment should include the two conditional tests, and there should be another set of parent brackets wrapping the (or...) and the resulting (add_list...) call.  Each branch of a (cond...) is effectively a list, with the first element in that list the test to see if the rest of the elements of that list are to be evaluated.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 3 of 3
aesh
in reply to: dgorsman

That did the trick, 

 

Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost