@DC-MWA wrote:
Ok... I got past the dimension edit part.
I now need the program to remeber the last input and make it default until changed by user.
Something like this?
(setq userinput1 (cond ((getkword (strcat "\nSLOPE DESCRIPTION: <" userinput1 ">: ")))
(userinput1)))
See attached file
(initget "R G B")
(setq *uc*
(cond
((getkword (strcat "\nChoose [Red/Green/Blue] <"
(setq *uc* (cond (*uc*) ("R"))) ">: "))
)
(*uc*)
)
)
Working example.
This allows user to choose a color: Red, Green or Blue. (this is used for marking parts of a drawing. red needs to be dismanteled, Blue is new, Green is for comments/information.)
This will show either the previous user choice (stored in global *uc*) -or- the default ("R")
In case the user hits enter, it uses whatever is set (previous or default).
However, all you are asking for is a string.
So, I would suggest you drop the getkword and replace it by getString. this also makes the initget obsolete.
In your case that would look something like:
(setq *userinput1*
(cond
((getstring (strcat "\nSLOPE DESCRIPTION <"
(setq *userinput1* (cond (*userinput1*) ("default description"))) ">: "))
)
(*userinput1*)
)
)
Note: as stated before, to remember the user input, the variable needs to be a global. Which is indicated by the asterix (before and after). (this is just a visual thing for yourself and others to see it is a global)
By default any variable is global, unless you declare it to be local within the function definition.
(setq var "\nThis is a global")
(defun c:blahblah ( / var var2)
(setq var "\nThis is a local variable")
(setq var1 "\nThis is global again")
(setq var2 "\nAnother local variable")
(princ var)
)
(c:blahblah)
(princ var)
(princ var1)
(princ var2)
Results in:
This is a local var
This is a global
This is a global again
nil
Note: i used var twice, but they are not the same variable. One is a global, the other is bound to the function, with each its own value. (demonstrated by the nil, instead of "Another local variable" for var2)