home *** CD-ROM | disk | FTP | other *** search
- 10 ! ************************************************
- 20 ! Example: Using ON EVENT
- 30 !
- 40 ! This program shows one way ON EVENT can be
- 50 ! used for error handling.
- 60 !
- 70 ! ***********************************************
- 80 !
- 90 ON SIGNAL 15 CALL Sig15_handler
- 100 ON ERROR CALL Error_handler
- 110 A=0/0
- 120 DIALOG "INFORMATION","After divide by zero error"
- 130 END
- 140 !
- 150 SUB Sig15_handler
- 160 ASSIGN @Printer TO WIDGET "PRINTER"
- 170 CONTROL @Printer;SET ("X":0,"Y":0,"TITLE":"Event Record")
- 180 CONTROL @Printer;SET ("TEXT":"ERROR: "&ERRM$)
- 190 CONTROL @Printer;SET ("APPEND TEXT":"ON SIGNAL 15 System Priority: "&SYSTEM$("SYSTEM PRIORITY"))
- 200 STATUS @Printer;RETURN ("WIDTH":X,"HEIGHT":Y)
- 210 !
- 220 ASSIGN @Button TO WIDGET "PUSHBUTTON";SET ("VISIBLE":0,"RESIZABLE":0,"TITLE":"","LABEL":"PUSH ME")
- 230 STATUS @Button;RETURN ("WIDTH":W,"HEIGHT":H)
- 240 CONTROL @Button;SET ("X":(X-W)/2,"Y":(Y-H)/2,"VISIBLE":1)
- 250 ON EVENT @Button,"ACTIVATED",15 GOTO Okd
- 260 LOOP
- 270 WAIT FOR EVENT
- 280 CONTROL @Printer;SET ("APPEND TEXT":"WAIT FOR EVENT terminated and branch taken (this statement never executed).")
- 290 END LOOP
- 300 Okd: CONTROL @Printer;SET ("APPEND TEXT":"Branch taken.")
- 310 WAIT 1
- 320 SUBEND
- 330 SUB Error_handler
- 340 DIALOG "INFORMATION","Now in error handler. System Priority: "&SYSTEM$("SYSTEM PRIORITY")&CHR$(10)&"asserting signal 15"
- 350 SIGNAL 15
- 360 ERROR SUBEXIT
- 370 SUBEND
-