Michaels Posted February 27, 2011 Share Posted February 27, 2011 Hello. I wonder why these codes are not working good and return an error message . (setq a (if a b "1")) (if (progn (initget (+ 1 2 4) "1/4 1/2 2 1.5") (setq a (cond ((getkword (strcat "\n Enter Inch Number [1/4 1/2 2 1.5] <"(atoi a 3 2)" > :")))(T a)))) (setq b a) ) Thanks Quote Link to comment Share on other sites More sharing options...
pBe Posted February 27, 2011 Share Posted February 27, 2011 At least use "\" to give the illusion of fraction (setq a (if a b "1")) (if (progn (initget (+ 1 2 4) [color=blue]"1\\4 1\\2 2 1.5")[/color] (setq a (cond ((getkword (strcat "\n Enter Inch Number [[color=blue]1\\4/1\\2/2/1.5][/color] <" [color=blue]a[/color]" > :")))(T a)))) (setq b a) ) To get a better appearance make sure dynmode is set to 1 no need for a variable conversion BTW: http://lee-mac.com/promptwithdefault.html for default tutorial Quote Link to comment Share on other sites More sharing options...
Michaels Posted February 27, 2011 Author Share Posted February 27, 2011 Thanks . But that does not save the given data to variable a which is need to be changed according to the last given data . I guess that failed due to the un-existence of (atoi a 3 2) . What you think . Quote Link to comment Share on other sites More sharing options...
pBe Posted February 27, 2011 Share Posted February 27, 2011 ah.... i see by doing the "\" you cant convert varaible a to a floating number but if you use "/" , it cant be recognize by getkword as 1/4 Maybe therse a escape code for that... hmmmm BTW use distof instead, 1/4 is 0.25 , converting 1/4 to integer will result to 1, besides there is no mode argument for itoa I'll get back to you... hang on Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2011 Share Posted February 27, 2011 Think about what type of data the variable 'a' points to: (setq a (cond ( a ) ("1"))) (if (progn (initget "0.25 0.5 2 1.5") (setq a (cond ( (getkword (strcat "\n Enter Inch Number [0.25/0.5/2/1.5] <" a "> :") ) ) ( a ) ) ) ) (princ (strcat "You have Selected: " a)) ) Quote Link to comment Share on other sites More sharing options...
Michaels Posted February 27, 2011 Author Share Posted February 27, 2011 Thank you Lee. Although that would save the chosen number by a user to the argument , the second time that I use it I can not hit enter to get the last saved number to the variable . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2011 Share Posted February 27, 2011 Although that would save the chosen number by a user to the argument , the second time that I use it I can not hit enter to get the last saved number to the variable . It saves it to a variable, not argument. You had the initget bit 1 set preventing the user from pressing enter - I edited my post to removed the initget bit values. Since you require a 'real' value, I would be more inclined to approach it this way: (defun c:test ( / allowedvalues tmp ) (setq allowedvalues '(0.25 0.5 2.0 1.5) *def* (cond ( *def* ) ( (car allowedvalues) ))) (while (not (member (setq tmp (cond ( (getreal (strcat "\nEnter Inch Number [0.25/0.5/2.0/1.5] <" (rtos *def* 2 2) ">: ") ) ) ( *def* ) ) ) allowedvalues ) ) (princ "\nPlease Select from [0.25/0.5/2.0/1.5].") ) (setq *def* tmp) (princ (strcat "\nYou have selected: " (rtos *def* 2 2))) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted February 27, 2011 Share Posted February 27, 2011 oh welll. i'm too slow of a typist .. i was about to suggest using decimal instead of fraction. but i could have sworn i've done it once... i'll keep digging EDIT: geez Lee, you sure can code and type fast.... Quote Link to comment Share on other sites More sharing options...
Michaels Posted February 27, 2011 Author Share Posted February 27, 2011 That's more than great Lee . Thank you A great Thanks also to pBe . Appreciated a lot. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2011 Share Posted February 27, 2011 EDIT: geez Lee, you sure can code and type fast.... Too much practice That's more than great Lee . Thank you A great Thanks also to pBe . Appreciated a lot. You're welcome Michaels - hopefully my code is understandable. 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.