Tharwat Posted June 16, 2010 Share Posted June 16, 2010 Hi, Suppose that user pressed enter instead of giving a value. How could I let the program keep on running and return only values that are given from user. for example: (setq pcs1 (getdist "\nLength of First Peice: ")) ;suppose any number (setq pcs2 (getdist "\nLength of Second Peice: ")) ;suppose (setq pcs3 (getdist "\nLength of Third Peice: ")) ; suppose How to get only the giving values and running the program normally . ..? Many Thanks. Tharwat Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 16, 2010 Share Posted June 16, 2010 Check the INITGET statement, will allow to constrain user answer and compare that answer with nil - this is returned when is hit instead of an input. Regards, Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 16, 2010 Author Share Posted June 16, 2010 Thanks msasu. All (initget) values are with not allowed as following, Establishes limitations on the user responses allowed by the next get- function (initget 1) null input not allowed ("null input" means 'Enter' by itself) (initget 2) 0 input not allowed (initget 3) null input and 0 input not allowed (3 = 1 + 2) (initget 4) negative values not allowed (initget 5) null input and negative values not allowed (5 = 1 + 4) (initget 6) 0 input and negative values not allowed (6 = 2 + 4) (initget 7) null input, 0 input, and negative values not allowed (7 = 1 + 2 + 4) (initget cancels limits check (initget 16) (not used) (initget 32) causes get- functions that include a base point to display a rubber band cursor or window that is highlighted rather than solid (initget 64) Z coordinate not allowed in next getdist function (initget 128) allows arbitrary input (accepts any "key word") (initget "A B C") allows the user to enter "A" "B" "C" "a" "b" or "c" in response to the next get- function (in addition, of course, to the possibility of entering an integer if the next get- function is getint, a real if it is getreal, etc.) Subsequent programming must be set up to handle these strings. I cloud not find something allowed. Regards, Tharwat Quote Link to comment Share on other sites More sharing options...
jammie Posted June 16, 2010 Share Posted June 16, 2010 Maybe an IF statement could be used for the test There are probably a few ways of doing it. Just a sample (if (setq Input (getdist "\nLength of First Peice: " ))(setq pcs1 Input)) (if (setq Input (getdist "\nLength of Second Peice: "))(setq pcs2 Input)) (if (setq Input (getdist "\nLength of Third Peice: " ))(setq pcs3 Input)) Or if you would like to store a default (or pcs1 (setq pcs1 10.0)) (if (setq Input (getdist (strcat "\nLength of First Peice [" (rtos pcs1) "] : " ))) (setq pcs1 Input)) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 16, 2010 Author Share Posted June 16, 2010 Thank you sooooooo much jammie Both of proposals were Wonderful... and in particular the second one which is saves the value. Thanks again and again . With all my respects Tharwat Quote Link to comment Share on other sites More sharing options...
jammie Posted June 16, 2010 Share Posted June 16, 2010 Your welcome! Glad to help Regards Jammie Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 16, 2010 Share Posted June 16, 2010 Two more examples: (setq pcs1 (cond ((getdist "\nLength of First Peice <10.0>: ")) (10.0) ) ) (setq *pcs1* (cond ((getdist (strcat "\nLength of First Peice <" (rtos (cond (*pcs1*) ((setq *pcs1* 10.0)) ) ) ">: " ) ) ) (*pcs1*) ) ) 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.