Setting Variables back if User Cancelled Routine

sashk

Usenet Archive
Joined
Jul 14, 2003
Messages
69
Reaction score
0
Hello All,

I am not an expert in lisp, but I can do a few things. Here is my problem:

Our lisp routines, when invoked, set some variables, and then when the routine is done, it will set them back. For example, this--> (setvar OLDOS (getvar "osmode")). And then, at the end of the routine, it will do this
-->(setvar "osmode" OLDOS). Now, sometimes, people will cancel the routine right when it has been invoked. How can I make it so that if the user hits the ESC button, it will revert back to their settings?? Thanks
 
Alex, it did not download. It says that there are no attachments. Can you re-load it??
 
(defun C:Test (/ *Error* oldHighlight)
;;; Error handler
(defun *Error* (Err)
(cond ((not Err))
((member Err '("Function cancelled" "quit / exit abort"))) ((princ (strcat "\nError: " Err)) (cond (*Debug* (vl-bt))))) (if oldHighlight (setvar "Highlight" oldHighlight)) (princ)) ;;; Main code (setq oldHighlight (getvar "Highlight")) (setvar "Highlight" 0) (command "._Erase" "_si" pause) ;;; Normal exit (*Error* nil))
 
You didn't follow my example real close, did you? ;-)

1) Unless you *want* to overwrite the global error handler, it should be embedded in the main function, and declared as local.

2) You are never saving the old status of any of your setvars. See my sample.

3) You are never restoring your setvars in the error handler. You only pasted my error handler outside of your function and didn't modify it to fit the setvars you are concerned about.
 
Robert, I noticed that right after I posted the thing. I am not an expert with lisp. Here is what I tried, but still no luck. Can you show me an example that would work? Here is mine. Can you modify it so it does work? Thanks
 
Yes, I found the problem again. This is what happens when you come back from vacation. Brain seems to slow down. Why the "undo end" at the beginnig part of the routine? Or, is this really the end of the routine, even though it is at the top. If the user ran a long routine, and then did undo, will it really undo all of the steps, even though the "undo begin" is in the second part of the routine? (I hope that made sense.

Robert, you have been a huge help. Thanks for your time and patience. I'm learning this stuff at time passes!
 
The end at the beginning (???) is in case another program failed to close their own undo group. That way you own code won't get grouped with the other program's.
 

Latest threads

Back
Top