Keeping user input when re-running lisp

Discussion in 'AutoCAD' started by Xolo, Jan 19, 2004.

  1. Xolo

    Xolo Guest

    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
     
    Xolo, Jan 19, 2004
    #1
  2. Xolo

    Rudy Tovar Guest

    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)
    )
     
    Rudy Tovar, Jan 20, 2004
    #2
  3. Xolo

    Scot-65 Guest

    :

    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
     
    Scot-65, Jan 20, 2004
    #3
  4. Xolo

    Xolo Guest

    Again, my hat's off to you. Thank you both for your input and information
     
    Xolo, Jan 20, 2004
    #4
  5. Xolo

    CAB2k Guest

    CAB2k, Jan 20, 2004
    #5
  6. Xolo

    Scot-65 Guest

    :

    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
     
    Scot-65, Jan 21, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.