[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

Part1 - Part2 - Single Page

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]


[27] How to break a command in Lisp?


  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>]
  ..



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 October 22 2009 @ 05:22 AM

Some parts © 2009 Advameg, Inc.