Q(uick)BASIC Statement: SIGNAL

Quick View

SIGNAL

These statements enable, disable, or suspend event trapping for an OS/2 protected-mode signal

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • SIGNAL(n%) ON
  • SIGNAL(n%) OFF
  • SIGNAL(n%) STOP
Description/Parameter(s)
  • The argument n% identifies a signal specified in a previous ON SIGNAL statement.

Usage Notes

  • SIGNAL(n%) ON enables trapping of OS/2 signal n%. If an OS/2 protected- mode signal occurs after a SIGNAL(n%) ON statement, the routine specified in the ON SIGNAL statement is executed.
  • SIGNAL(n%) OFF disables trapping of OS/2 signal n%. No trapping takes place until another SIGNAL(n%) ON statement is executed. Events occurring while trapping is off are ignored.
  • SIGNAL(n%) STOP suspends trapping of OS/2 signal n%. No trapping takes place until a SIGNAL(n%) ON statement is executed. Events occurring while trapping is suspended are remembered and processed when the next SIGNAL(n%) ON statement is executed. However, remembered events are lost if SIGNAL(n%) OFF is executed.
  • When a communications event trap occurs (that is, the GOSUB is performed), an automatic SIGNAL(n%) STOP is executed so that recursive traps cannot take place. The RETURN from the trapping routine automatically executes a SIGNAL(n%) ON statement unless an explicit SIGNAL(n%) OFF was performed inside the routine.
  • For more information, see Chapter 9, "Event Handling" in the Programmer's Guide.
Example

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

See also: