Keeping user input when re-running lisp

Xolo

Usenet Archive
Joined
Aug 6, 2003
Messages
80
Reaction score
0
One more question.

How do I allow for the previous user inputs in a lisp routine, be set as the default (just hitting enter uses the last number entered) for the next time running the same lisp routine? Using the same example;

(setq p1 (getpoint "\nPick Point 1:"))
(setq p2 (getpoint "\nPick Point 2:"))

Thanks for the help again,

Xolo
 
You set it to a floating variable while the drawing is open.

Or may use a place to store the information, in your case the distance to a file, reg, or dictionary, xdata, uservariable, etc.

(defun c:yourfun (/ p1 p2)

(setq p1 (getpoint "\nPick First: "))
(if p1
(progn
(setq p2 (getpoint p1 "\nPick Next: "))
(if p2
(progn
(setq Your_dist (distance p1 p2));placing this value above will clear value. ) ) ) ) (princ)
)
 
:

Xolo,

I have many "Remember From Last Time" routines here.
I will post a partial user input.

Briefly, I use "UserXX" as the gremlin for my routines, where "XX" is the routine name. If I need more than one of these, I tend to lean towards "UserXX2", UserXX3", etc...

Remember, you will have to initialize this gremlin
at the beginning of the program.

This partial example is from my routine called "Auto Number". This requires a starting number and ending number.

(if (not useran) (setq useran 1) );if
(setq n1 (getint (strcat "\nAuto Number (First number)[" (itoa useran) "]: ")))
(if n1 (setq useran n1))

Use useran as one value, as n1 is reused for the last number (this example only). When last number is achieved, set useran to the last number (this example 1+ useran in a while loop).

Variations to include Reals, Strings (with Intiget), and Points.

If you need to store the value, the USERINTEGER and USERREAL is stored in the drawing (1 - 5). Do not go overboard with these user slots, as you only have 10 to work from.

Hope this helps.

Scot-65
 
Again, my hat's off to you. Thank you both for your input and information
 
:

Xolo,

I saw the previous post only after posting my message.

My method keeps these gremlins from intefering with other programs. Say, (setq A "Text") for one program. (do not clear A at end of program or in error message).

You get a routine from others that sets A to say, a REAL. Original program crashes. Must reload original program.

Taking over the menu here, there were many like that. Yucky.

2) The wording of your original post did not specify which of the two points you wished to save, nor if the points were to be repeated inside the program only. (getvar "LASTPOINT") was to be my other answer since you did not specify saving the value in the program as opposed to saving outside the program, to be called upon at a later time...

3) I do not write to an external file.
I do not read from an external file.
This is too much baggage to carry around.

Scot-65
 

Latest threads

Back
Top