View Single Post
Old 07 July 2015, 14:36   #37
BigFan
Registered User
 
BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
Interrupt Signals

Before we continue to clean up the code from the previous example, we inspect
the tools provided to debug our code.

First those options from inside code:

Signal On <option>
This allows your code to be aware of interupts caused by errors or signals from
outside, like Ctrl+C to interupt program execution
Each option has to be triggered in a single statement. When signal is on, you
need a label of same name to jump at. The label has to be outside of loops
or conditional blocks.

Code:
/**/
Signal on error
Signal on break_c
Signal on break_d

Options Results

Address .....

blablabla 

your code runs here

....

Error: /* label for signal on error*/
Echo "Damn it"
Echo sigl /* sigl is special variable, stores the source line that causes an error*/

Break_c: /* label for ctrl+c*/
Exit

Break_d: /* label for ctrl+d*/
Echo "Why?? Don't you like me?"
Exit
Now when pressing Ctrl+C no error is posted as we told to just exit in this case.
With Ctrl+D we interrupt scripts and receive a message from our wailer, then exit.

If an error occurs during runtime, we swear, then ask for the line where the error
occured. An error is every return code (stored in internal var "RC") greater
than zero. Pobably you know those error levels from DOS : 5 , 10 , 20.
Same for ARexx. You can lower or raise the error level with Options Failat.

Signal on [] reacts to
BREAK_C; BREAK_D; BREAK_E ;BREAK_F
ERROR
HALT /* interrupt call from outside*/
IOERR /*device io like disk access */
NOVALUE /* code uses uninitialized symbol */
SYNTAX /* execution error, useful for internal syntax errors*/
BigFan is offline  
 
Page generated in 0.13102 seconds with 11 queries