Q(uick)BASIC Keyword: ON
Quick View
ON Keyword
Different Uses
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Description/Parameter(s)
- The ON keyword performs different actions as part of several statements:
- Enables error trapping when used with the ON ERROR statement.
- Enables event trapping when used with the event ON statements (COM ON, KEY ON, PEN ON, PLAY ON, STRIG ON, and TIMER ON).
- Specifies an event to trap when used with the ON event statements (ON COM, ON KEY, ON PEN, ON PLAY, ON STRING, and ON TIMER).
- Specifies an expression to evaluate when used with the ON...GOSUB and ON...GOTO statements.
Description/Parameter(s)
The ON keyword is used in various statements to trap events:
⮜ ON COM(n) ⮞ | events on communications port n | ⮜ COM(n) ON ⮞ |
⮜ ON KEY(n) ⮞ | a keystroke on key n | ⮜ KEY(n) ON ⮞ |
⮜ ON PEN ⮞ | lightpen events | ⮜ PEN ON ⮞ |
⮜ ON PLAY(n) ⮞ | less than n notes in music buffer | ⮜ PLAY ON ⮞ |
⮜ ON STRIG(n) ⮞ | events on joystick trigger n | ⮜ STRIG(n) ON ⮞ |
⮜ ON TIMER(n) ⮞ | timer events | ⮜ TIMER ON ⮞ |
⮜ ON UEVENT ⮞ | user-defined events | ⮜ UEVENT ON ⮞ |
Other uses of the ON keyword are:
⮜ ON ERROR ⮞ | - to enable error handling and specify the error-handling routine |
⮜ ON...GOSUB ⮞ | - to branch to one of a list of subroutines |
⮜ ON...GOTO ⮞ | - to branch to one of a list of line labels |
Description/Parameter(s)
The ON event statements are used to trap events. For further information, see ON COM, ON KEY, ON PEN, ON PLAY, ON SIGNAL, ON STRIG, ON TIMER, or ON UEVENT:
Specifies a trap | Type of event | Enables the trap | Available in DOS or OS/2 protected mode |
⮜ ON COM(n) ⮞ | Events on a communications port | ⮜ COM(n) ON ⮞ | DOS & OS/2 |
⮜ ON KEY(n) ⮞ | A keystroke | ⮜ KEY(n) ON ⮞ | DOS & OS/2 |
⮜ ON PEN ⮞ | Lightpen events | ⮜ PEN ON ⮞ | DOS only |
⮜ ON PLAY(n) ⮞ | Fewer than queluelimit% notes in the background-music queue | ⮜ PLAY ON ⮞ | DOS only |
⮜ ON SIGNAL ⮞ | An OS/2 signal event | ⮜ SIGNAL ⮞ | OS/2 only |
⮜ ON STRIG(n) ⮞ | Events on a joystick trigger | ⮜ STRIG(n) ON ⮞ | DOS only |
⮜ ON TIMER(n) ⮞ | Timer events | ⮜ TIMER ON ⮞ | DOS & OS/2 |
⮜ ON UEVENT ⮞ | User-defined events | ⮜ UEVENT ON ⮞ | DOS & OS/2 |
See also: