Jump to content

If/Then to accept multiple possiblilities


Recommended Posts

Posted

When creating an if/then senario in lisp's, how do you do consider the expression true for more than one value.

 

Example, I need to ask the user what viewport they want to change, Top, Front, or Right... But I want it to accept "Top" or "T" for Top.

 

Does this work?:

 

(setq vpn (if (= vp (or "Top" "T") (2))

 

Would "T" or "Top" set vpn as 2?

 

Also, is there a way for me to test on my own?

Posted

Try this with T and Top (also F, Front, R, Right)

(initget 1 "Top Front Right")
(setq ans (getkword "Top, Front or Right"))
(cond
 ((= ans "Top") (setq vpn 2))
 ((= ans "Front") (setq vpn 3))
 ((= ans "Right") (setq vpn 4))
 )

Posted

Look at these 2 functions

(initget "Abc Def _Ghi Jkl")(getkword "\nEnter an option (Abc/Def): ")Entering A returns Ghi and entering _J returns Jkl.

  • 2 weeks later...
Posted

I got the initget/getkword functions to work for me in this case, but now would I do a if/then that would allow multiple correct inputs, example:

 

if x=(top or bottom), then do a function, else exit program

Posted
I got the initget/getkword functions to work for me in this case, but now would I do a if/then that would allow multiple correct inputs, example:

 

if x=(top or bottom), then do a function, else exit program

 

You could use either the or function, or maybe the member function :)

Posted

lol, I now this is going to sound funny, but I need help on using Visual Lisp's help...

 

I searched for the "or" function and under the concept tab is says:

 

"$(or, val1 [, val2,…, val9])"

 

And I have a couple questions.

 

What's the "$" mean?

Why is ",val1,...,val9" in "[]" signs?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...