View Full Version : Zscript : Exception handling.
Is it possible to do exception handling in zscripts? If, for example, the user presses Escape while a script is running is it possible to trap that event and do any necessary script clean up before exiting?
It would be very useful and could save many headaches, like the one I have right now :)
I think the answer is no... :(
You can trap mouse click within loops statements, but i don't known a method to intercept keyboard press...
cameyo
p.s. but with ESC the script stop to run, then the virtual machine traps that key... :confused:
Thanks Cameyo,
I am mainly interested in the abnormal exiting of zscript plugins, the escape key in particular. But it would also be useful for "normal" zscripts that are shown in the zscript window. Being able to detect a change of zscripts (the arrow keys) or the loading of a new script would be useful.
Svengali
05-19-04, 12:21 PM
Hi TV,
Here is code I use in Moldy to capture left arrow and right arrow keypress to save the data for captured object views... All it does is setup two hidden buttons to intercept the assigned hotkeys... then after saving out data, invokes the appropriate ZScript button.
//-------------------------------------------------------------------
// KEYBOARD INPUT Left Arrow
[PenMove,-MMx2,MMy-1]
//-------------------------------------------------------------------
[IButton,"","",
[RoutineCall, DumpVariables]
[IPress,ZSCRIPT:PREVIOUS]
,,-8,252,,4
]
//-------------------------------------------------------------------
// KEYBOARD INPUT Right Arrow
[PenMove,0]
//-------------------------------------------------------------------
[IButton,"","",
[RoutineCall, DumpVariables]
[IPress,ZSCRIPT:NEXT]
,,-8,254,,4
]
Wonder if something similar might work with ESC key?
Sven
Thanks Sven. The standard hotkey assignment will not do it. I guess you could call that event handling, I need to detect an abnormal end to a process, or exception handling.
Does not sound like it is possible. I was just hoping there was some secret feature :)
Svengali
05-20-04, 06:59 AM
Ah, I see the problem and guess there's no error trapping (I wished for that myself once or twice in ZScript).
Sven
vBulletin v3.0.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.