`prev Menu next`

CHARACTER INPUT

`CHARACTER INPUT s$`
waits for a key input and then assigns the character to a string variable s$

Enter key, BackSpace key, or ESC key stands for a character.
Enter stands for a character whose ordinal is 13,
Ctrl-Enter stands for a character whose ordinal is 10,
BackSpace stands for a character whose ordinal is 8,
ESC stands for a character whose ordinal is 27.
Any other key that does not stand for any character such as a function key or an arrow key is ignored.

Supplement.
A PROMPT clause, a TIMEOUT clause or an ELAPSED clause can be included in a CHARACTER INPUT statement as in a INPUT statement.

Example.
`CHARACTER INPUT PROMPT "Press the number that you selected.":s$`

In addition, a CLEAR clause or a NOWAIT clause can be written in a CHARACTER INPUT statement.
Example.
`CHARACTER INPUT CLEAR:s$`
All characters that lie in the typeahead buffer are removed before key input.
Example.
`CHARACTER INPUT NOWAIT:s$`
do not wait for a key input. s$ remains the former value if the typeahead buffer is empty.
When plural clauses are included, they must be separated by a comma or commas. The order is not definite.
Examples.
`CHARACTER INPUT ELAPSED n ,CLEAR: s$
CHARACTER INPUT CLEAR, ELAPSED n: s$
`
The number of characters in the typeahead buffer can be known via the following statement, where n is a numeric variable.
`ASK CHARACTER PENDING n`

See also SET ECHO