Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.cad.autocad AutoLISP FAQ (part 2/2) - samples, code
Section - [27] How to break a command in Lisp?

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.cad.autocad AutoLISP FAQ (part 2/2) - samples, code
Previous Document: [26] EED Extended Entity Data: Select, Get and Store
Next Document: [27.1] How to do an unlimited number of user prompts? [new]
See reader questions & answers on this topic! - Help others by sharing your knowledge
  Also: "How do I press Break in AutoLISP?"

  (command) without parameters works just like hitting Ctrl-C under
  DOS or Esc under Windows at the command prompt. But it does not
  mimic Esc in a dialog box. And it does not work within
  SCRIPTS. (command nil) is the same as (command).

  (command) breaks only the command functions, e.g. if you use the
  command "DIM" inside AutoLISP, you must interrupt it by (command)
  after dimensioning.

  But it doesn't work, if you try to interrupt a lisp loop. There is
  another function (exit) or (quit) -they do the same-, which
  immediately break a Lisp program.

  Example:

  (while T ; do         ; a never ending loop
    (princ "\nEnter a=")
    (setq a (getint))
    (if (zerop a)(exit)) ; Breaks Lisp and returns to the command mode.
  )

  In this example (command) doesn't work. (exit) works exactly as
  Ctrl-C. It prints "error: quit / exit abort" and outputs all nested
  functions. To provide "silent" break you must include this error
  message to an error handling function, e.g.:

  (setq *olderr* *error* *error* my-error)
  (defun MY-ERROR (s)
    (if (not (member s            ; msgs of the english version:
       '("Function cancelled" "console break" "quit / exit abort")))
      (princ (strcat "\nError: " s))
    )
    (setq *error* *olderr*)
  )

  For scripts use this workaround by defining (cancel) in lisp, simply
  (defun SCRIPT-CANCEL ()
    (command)
    (command "resume")
  )
  and in a SCRIPT.SCR:
  ..
  [<script commands>]
  (script-cancel)
  [<more script commands>]
  ..

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.cad.autocad AutoLISP FAQ (part 2/2) - samples, code
Previous Document: [26] EED Extended Entity Data: Select, Get and Store
Next Document: [27.1] How to do an unlimited number of user prompts? [new]

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
rurban@xarch.tu-graz.ac.at (Reini Urban)





Last Update March 27 2014 @ 02:11 PM