Sweety Posted November 29, 2010 Share Posted November 29, 2010 Hello GUYS. How could I save the value to the argument ( Len ) to be used once again in the same routine by pressing Enter ? (initget (+ 2 4)) (setq Len (getdist "\n SpecifyLength of the element :")) Thankxxxxxxxxxxxx Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 29, 2010 Share Posted November 29, 2010 Some information I have given in the past: ;; Initget / GetK(ey)word Examples ;; © Lee Mac 2010 ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;; Note 1: On Prompt String Format ;; In all examples, to achieve correct display ;; when DYNamic Input (DYNMODE=1) is enabled, ;; prompt string must be formatted thus: ;; [Option1/Option2/Option3] ;; Or, with default: ;; [Option1/Option2/Option3] <Option1> ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;; Note 2: On Global Variable Format ;; In all examples utilising global variables ;; asterisks are included in variable names to decrease ;; risk of variable names clashing with unlocalised variables ;; from other programs. Asterisks are used for no other purpose. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;; 1. Force User Input (initget bit 1) (initget 1 "Alpha Beta Gamma") (setq ans (getkword "\nChoose [Alpha/Beta/Gamma]: ")) ;; User must select a choice to continue, else ;; Esc must be used to cancel evaluation ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;; 2. Preset Default (Alpha) ;; a) (initget "Alpha Beta Gamma") (setq ans (cond ( (getkword "\nChoose [Alpha/Beta/Gamma] <Alpha>: ") ) ( "Alpha" ))) ;; b) (initget "Alpha Beta Gamma") (setq ans (getkword "\nChoose [Alpha/Beta/Gamma] <Alpha>: ")) (if (not ans) (setq ans "Alpha")) ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;; 3. Dynamic Default (utlisation of Global Variable: *ans*) ;; a) (or *ans* (setq *ans* "Alpha")) (initget "Alpha Beta Gamma") (setq *ans* (cond ( (getkword (strcat "\nChoose [Alpha/Beta/Gamma] <" *ans* ">: ") ) ) ( *ans* ) ) ) ;; b) (if (not *ans*) (setq *ans* "Alpha")) (initget "Alpha Beta Gamma") (setq *ans* (cond ( (getkword (strcat "\nChoose [Alpha/Beta/Gamma] <" *ans* ">: ") ) ) ( *ans* ) ) ) ;; c) (initget "Alpha Beta Gamma") (setq *ans* (cond ( (getkword (strcat "\nChoose [Alpha/Beta/Gamma] <" (setq *ans* (cond ( *ans* ) ( "Alpha" )) ) ">: " ) ) ) ( *ans* ) ) ) Quote Link to comment Share on other sites More sharing options...
Sweety Posted November 29, 2010 Author Share Posted November 29, 2010 Thanks Lee. But none of examples are dealing with Numbers, though according to my way of using the argument. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 29, 2010 Share Posted November 29, 2010 But none of examples are dealing with Numbers, though according to my way of using the argument. That's where you need to use your initiative. Quote Link to comment Share on other sites More sharing options...
asos2000 Posted November 30, 2010 Share Posted November 30, 2010 I hope this example match your needs (if (not rnm:Pref) (setq rnm:Pref "") ) (setq rnm:Pref (getstring T (strcat "\nType prefix:(If you want to delete prefix type ' ' (press SPACE key on keyboard) <" rnm:Pref "> :" ) ) ) Quote Link to comment Share on other sites More sharing options...
Sweety Posted November 30, 2010 Author Share Posted November 30, 2010 I hope this example match your needs (if (not rnm:Pref) (setq rnm:Pref "") ) (setq rnm:Pref (getstring T (strcat "\nType prefix:(If you want to delete prefix type ' ' (press SPACE key on keyboard) <" rnm:Pref "> :" ))) It's not. Because you should (cond) function plus (T + argument) . And when you hit enter it will return "nil" . Try again. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted November 30, 2010 Share Posted November 30, 2010 Here's how I do it: [b][color=BLACK]([/color][/b]setq ldef [b][color=FUCHSIA]([/color][/b]if deflen deflen 28[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]initget 6[b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]setq len [b][color=FUCHSIA]([/color][/b]getdist [b][color=NAVY]([/color][/b]strcat [color=#2f4f4f]"\nLength <"[/color] [b][color=MAROON]([/color][/b]rtos ldef 2 2[b][color=MAROON])[/color][/b] [color=#2f4f4f]">: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]or len [b][color=FUCHSIA]([/color][/b]setq len ldef[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]setq deflen len[b][color=BLACK])[/color][/b] The default is 28 the first time the program is run. The default changes with the current inputs. len needs to be localized as does ldef I leave deflen global so that it can be used with other programs. This could probably be compressed a some, but it is readable for me anyway. -David Quote Link to comment Share on other sites More sharing options...
Sweety Posted November 30, 2010 Author Share Posted November 30, 2010 Yes . This is the perfect way . Thank you Mr. David Appreciated Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 30, 2010 Share Posted November 30, 2010 Seriously, are you looking to learn or for someone to provide you with code? 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.