GET

From C64-Wiki

Jump to: navigation, search
BASIC keyword
Keyword:GET
Abbreviation:G, Shift+E
Type:Command
Token code:161/$A1
Handling routine
in BASIC ROM:
43899–43940
$AB7B–ABA4
List of all BASIC keywords


Remark: This article describes the BASIC-Command GET in BASIC V2 at the Commodore 64.

Typ: Command
General Programming-Syntax: GET <Variable>[, <Variable>...]


The BASIC-Command GET read serveral chars of the keyboard cache into a variable (string, floating point or integer) and can only use in a BASIC-program. When a char from the keyboard cache is singeled, in the cache is space for one more char. The keyboard cache can be store max. 10 chars, more input chars are ignored.

By using a numeric variable and the command is getting a non-numeric value, the BASIC error ?SYNTAX ERROR IN line appears. For prevention for these BASIC error, it should be used always a string. By using GET directly the BASIC-error "?ILLEGAL DIRECT ERROR" is viewed.

With the command GET can be developed own routine for keyboardinput and so disadvantages of the BASIC-Command INPUT can be avoided.

[edit] Examples

10 PRINT "Write max.20 chars, please: ";:GOSUB 1000
20 PRINT: PRINT "You have been written: ";B$
30 END
1000 REM simple GET-INPUT-Routine
1010 A$="": B$="": A=0: REM initial of the 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 routine for keyboardinput can be used all chars of the ASCII-Code-Table from 32 (<SPACE>-key) until 127 and 13 (<RETURN>- or <ENTER>-key). That means all punctuation marks, mathemathical chars, numbers (0-9), and all letters (A-Z in big and small). The using of a limited number of chars and keys is important, because control chars like <CRSR> can be destroy the screen mask. This routine is be finished by pushing the <RETURN>-key or by overrange of 20 chars.

BASIC V2.0-Commands of Commodore 64

ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC( | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB( | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT

 
Personal tools
Help and Feedback
In other languages