in BASIC ROM:
|List of all BASIC keywords|
Typ: Command General Programming-Syntax: GET <Variable>[, <Variable>...]
The BASIC command GET reads one or more chars from the keyboard cache into a variable (string, floating point or integer) and can only be used in a BASIC program. When a char from the keyboard cache has been read, there will be space in the cache for one more char. The keyboard cache can store at most 10 chars (by default), further input chars are ignored.
If the specified variable is a string variable then only one character will be read into it.
When a numeric variable has been passed to the command and it gets a non-numeric value, the BASIC error ?SYNTAX ERROR IN line appears. To prevent this BASIC error, it should always be used with a string variable. By using GET directly the BASIC-error "?ILLEGAL DIRECT ERROR" is displayed.
With the command GET, an own routine can be developed for keyboard input and so disadvantages of the BASIC command INPUT can be avoided.
10 PRINT "Type max. 20 chars, please: ";:GOSUB 1000 20 PRINT: PRINT "You have written: ";B$ 30 END 1000 REM simple GET-INPUT-Routine 1010 A$="": B$="": A=0: REM initialize variables 1020 GET A$: IF A$="" THEN 1020 1030 A=ASC(A$): IF (A<32 OR A>127) AND A<>13 THEN 1020 1040 B$=B$+A$: PRINT A$;: IF LEN(B$)<20 AND A$<>CHR$(13) THEN 1020 1050 RETURN
In this keyboard input routine, all chars of the ASCII code table can be used from 32 (<SPACE>-key) to 127 and 13 (<RETURN>-key). That means all punctuation marks, mathematical symbols, numbers (0-9), and all letters (A-Z in upper and lowercase). Limiting the number of valid chars and keys is important because control chars like <CRSR> can destroy the screen mask. This routine is finished by pushing the <RETURN>-key or by exceeding the 20 chars. Note that in this basic implementation, DEL key is ignored and so the user cannot correct typos. Also, there will be no blinking cursor.