bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SIGNAL Statements Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the EVENT and SIGNAL statements to enable event
'trapping. The ON SIGNAL statement passes control to a handling routine
'when Ctrl-Break is pressed.
 
'Note: The SIGNAL and ON SIGNAL statements can only be used in the OS/2
'operating system.
 
CLS
ON ERROR GOTO ErrHandler
PRINT "This program traps Control-Break in the OS/2 operating system."
EVENT ON
'Set up the signal event trap.
ON SIGNAL(4) GOSUB CtrlBreak
'Wait until the SIGNAL event occurs.
'Enable the trap.
SIGNAL(4) ON
DO
LOOP UNTIL UCASE$(INKEY$) = "Q"
PRINT "'Q' pressed - Program terminating normally."
END
 
CtrlBreak:
    PRINT "A SIGNAL(4) event occurred."
    PRINT "Press 'Q' to quit."
    RETURN
 
ErrHandler:
    SELECT CASE ERR
        CASE 73
            PRINT : PRINT "You cannot use the ON SIGNAL feature in DOS."
        CASE ELSE
    END SELECT
    END