Documentation Comments
Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.
RealityV15.1Online Documentation (MoTW) Revision 7
INPUTTRAP Statement (DataBasic) (m618703+inputtrap_s.htm)
Transfers control to a statement-label determined by the value of the trap character.
INPUTTRAP char-list [GO{TO} || GOSUB] label-list
char-list is the trap character list to be compared with a single character entered at an INPUT@ statement.
label-list is the list of labels of the statements where control is to be transferred.
The labels are any numeric or alphanumeric labels.
The INPUTTRAP statement works only with the INPUT@ statement.
The INPUTTRAP statement allows trapping on characters and transfers control to one of several statement-labels selected by the index value of the trap character in the character trap string. The INPUTTRAP statement is similar to the ON GOTO statement.
The trap is a one-character trap. The INPUT@ statement specifically checks to make sure that only one character was entered (if the INPUTTRAP statement has first been executed). You must have a one-to-one correspondence between the number of characters in the expression and the number of labels in the label-list. If the character entered at the INPUT@ statement matches a character in the trap string, then a branch is taken.
The GOTO version of the statement causes a direct branch. The GOSUB version of the statement causes a branch to a subroutine. The RETURN statement in the subroutine causes program control to return to the statement immediately following the INPUTTRAP statement.
INPUTTRAP "12345" GOTO 10,20,30,40,50 . . INPUT@(5,10) X
If a 2 is entered at the INPUT@ statement, control passes to statement label 20. If a 5 is entered, control passes to statement label 50.