Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

LISP

Status
Not open for further replies.

Hmo

Electrical
Nov 1, 2003
42
Hi there,

is it possible that when i'm executing a lisp program and i'm aborting it in the middle of the run with "Escape" that when that happens a few codelines will be executed.

Yes? Tell me how to write tis down please.

regards,
HMO
 
Replies continue below

Recommended for you

If error handling in the lisp is faulty or non-existing you will get an error message and a bunch of undiscernable code.

<Yes? Tell me how to write tis down please>

I'm not understanding this question. Could uou please rephrase it?
 
I think you are asking for a clean way to exit a LISP routine by pressing ESC and you don't want to see the normal garbage. There is a way. The following statements go inside your LISP routine:

1) Save the existing error function with this statement:
(setq olderr *error*)

2) Define a new function to intercept the ESC or other errors with something like this:

(DEFUN NewErr(s) ; Error handler
(SetVar "OSMODE" om)
(SetVar "CMDECHO" 0)
(setq *error* olderr)
(setq ans "An Error has ocurred")
(prompt ans)
(princ)
)

3) After the DEFUN in (2) above include the following:
(setq *error* NewErr)

3) At the end of your LISP routine, to make sure the error functin is restored to it's previous setting, add:
(setq *error* olderr)

This will hopefully get you started.
 
Look, i've got a lisp-function which sets at the begining a few variabels (osmode, ..) (and also saves the original values). At the end of the lisp-function this variables will be set back to the original values whiwh are saved at the beginning of the function.
However when i'm in the middle of the function and i want to abort it with "escape" the variables will not be set back to their original values saved in the beginning of the function.
Is it possibles to program the function so that when i'm aborting the function in the middle of the program that the original values of the variables saved in the beginning of that function will be set back to theirsoriginal values?

I'm just aasking of this is possibles and if the answer is yes how to do this?
 
Look yourself at my earlier reply perhaps a little closer this time. The key is to make a new error handler function within your LISP program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor