KeithXP Posted June 17, 2011 Share Posted June 17, 2011 Title says it all really. I am trying to allow the user to easily/quickly choose whether to do something by pressing any key (or perhaps the spacebar), or to bypass the option with 'Enter'. I cannot figure out how to do this with getkword or getstring, but I am fairly novice at autolisp and would be grateful for some pointers. thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2011 Share Posted June 17, 2011 Since a 'Space' is considered 'Enter' I think the closest you will get is: (initget "A B") (if (= "A" (getkword "\nChoose [A/B] <B>: ")) ... Do A ... ... Do B ... ) Perhaps have a read of my tutorial on the topic. I suppose you could use a workaround with getstring, but its not the best practice: (if (= "" (getstring t "\nPress Any Key for A, Enter for B: ")) ... Do B ... ... Do A ... ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2011 Share Posted June 17, 2011 Check this out buddy . Option A (if (not (eq (setq ansA (getstring "\n Press any key to go with A :")) "" ) ) (alert " Now you are going with option A ") (alert " It is not going with A") ) Option B (if (eq (setq ansB (getstring "\n Press Enter to go with B :")) "" ) (alert " Now you are going with option B ") (alert " It is not going with B") ) Tharwat Quote Link to comment Share on other sites More sharing options...
KeithXP Posted June 17, 2011 Author Share Posted June 17, 2011 Had not seen Tharwat's post when I chose this solution: (initget "Set Not") (setq ans (cond ( (getkword "\nSet planting area in name tag? [set/do Not set] <Set>: ")) ("Set"))) (if (= ans "Set") (progn (command "-vbarun" "SetPlantingArea")(princ) ) ) The 'setplantingarea' vba routine does not expect any arguments. The line (command "-vbarun" "setplantingarea") runs in isolation without returning any error. However, when run as part of the code snippet I get: Set planting area in tag? [set/do Not set] : s Set planting area in tag? [set/do Not set] : *Invalid selection* Expects a point or Last *Invalid selection* Expects a point or Last Function cancelledSelect area object: Command: Select destination tag: I have no idea what is generating the 'invalid selection' error! The SetPlantingArea routine works perfectly despite the error on the command line. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 19, 2011 Share Posted June 19, 2011 Why not nil = A no matter what else make it "B" (setq ans (getstring)) (if (= ans nil)(setq ans "A")(setq ans "B")) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 19, 2011 Share Posted June 19, 2011 I use a this scenario quite a lot: (initget "Yes No") (if (/= "No" (getkword "\nDo It - (Yes/No) <Y>: ")) (do_it)) This way a "Yes" or a nil ( enter ) both return T -David Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.