Ending Routine with "Enter"

Discussion in 'AutoCAD' started by Mal Kilpatrick, Jun 7, 2004.

  1. To All
    I have a small lisp routine to do consecutive numbering as follows:
    (defun c:wrinum ( / num)
    (prompt "\nHit ESC to exit")
    (setq num 1)
    (while (not
    (command ".text" pause 440 "0" num))
    (setq num (1+ num)
    ))(princ))

    I wish to be able to exit it by hitting Right button on mouse ("return") or
    "enter" on the keyboard.
    This does not happen as the pgm is waiting for a point and puts in the
    scale. Although hitting ESC works, I would like to make it a "cleaner" exit
    with the option of "Right Mouse etc, like most of acad's commands.

    Any help greatly appreciated.

    Mal
     
    Mal Kilpatrick, Jun 7, 2004
    #1
  2. Mal Kilpatrick

    Jon Guest

    (defun c:wrinum ( / num txtpt)
    (prompt "\nHit ESC to exit")
    (setq num 1)
    (setq txtpt (getpoint "\nText Insertion Point : "))
    (while txtpt
    (command ".text" txtpt 440 "0" num))
    (setq num (1+ num)
    (setq txtpt (getpoint "\nText Insertion Point : "))
    )
    (princ)
    )

    Jon
     
    Jon, Jun 7, 2004
    #2
  3. Mal Kilpatrick

    Jürg Menzi Guest

    Hi Mal
    'command' returns always 'nil'. Because of this, you can't leave the
    while loop. Possible solution:

    (defun c:wrinum ( / num txtpt)
    (setq num 1)
    (while (setq txtpt (getpoint "\nText Insertion Point <Exit>: "))
    (command "_.TEXT" txtpt 440 0 num))
    (setq num (1+ num)
    )
    (princ)
    )

    Cheers
     
    Jürg Menzi, Jun 7, 2004
    #3
  4. Mal Kilpatrick

    Jürg Menzi Guest

    Oops... hitting send button too fast:

    (defun c:wrinum ( / num txtpt)
    (setq num 1)
    (while (setq txtpt (getpoint "\nText Insertion Point <Exit>: "))
    (command "_.TEXT" txtpt 440 0 num)
    (setq num (1+ num))
    )
    (princ)
    )

    Cheers
     
    Jürg Menzi, Jun 7, 2004
    #4
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.