Top  Previous  Next


The INPUTTRAP statement defines special actions for INPUT @ and INPUTFIELD.





INPUTTRAP expr GOTO label1 {, label2...}

INPUTTRAP expr GOSUB label1 {, label2...}




exprevaluates to a string containing the characters to be trapped.


label1...are labels within the current program module.



The INPUTTRAP statement defines a set of characters that to be handled as special cases if used as a single character string entered for INPUT @ or INPUTFIELD. When the typed string is one of the characters defined in expr, the program performs a GOTO or GOSUB to the corresponding label from the list supplied in the INPUTTRAP statement. The variable into which input was being performed will be set to a null string.


If the number of characters in expr exceeds the number of labels, detection of a trapped character for which there is no corresponding label will jump to the last label in the list.


Specifying expr as a null string cancels any currently active INPUTTRAP action. Used in this way the syntax is unchanged and hence there must be at least one label present even though it will never be used.


When using the GOSUB form, returning from the subroutine will continue execution at the statement following the INPUTTRAP, not the statement following the INPUT @ or INPUTFIELD.


If both INPUTTRAP and INPUTNULL are used for the same character, INPUTNULL has precedence.





See also: