GET(hash)

From C64-Wiki
Jump to navigationJump to search
Disambiguation The title of this article is ambiguous. GET (Disambiguation).
BASIC keyword
Keyword: GET#
Abbreviation: ./.
Type: Command
Token code: ---/---
Handling routine
in BASIC ROM:
---;---
$----;----
List of all BASIC keywords


Remark: This article describes the BASIC command GET# in BASIC V2 on the Commodore 64.

Type: Command
General Programming-Syntax: GET# <logic file number>,<variable>[,<variable>...]

The BASIC command GET# reads single characters from the specified device or the opened file. Before GET# can be used, it is necessary to open the device or the file with the command OPEN with the same logical file number. The character read in this way is stored in a variable (string, floating point, integer). If this variable is of a numeral type and the character is no numeral, the interpreter will report a "?SYNTAX ERROR IN line" XYZ. Therefore, string variables are preferable to foolproof the use of GET#. Furthermore, GET# cannot be used outside of BASIC programs. Otherwise an "?ILLEGAL DIRECT ERROR" will occur.

When reading from tape or disk, GET# converts incoming CHR$(0) to an empty string.

After the end of a file on a disk, GET# continuously returns CHR$(199). This can be avoided by detecting the end-of-file with the STATUS command.

All characters are accounted for. An exception is the use of GET# on the screen. After every reading operation from the screen, the cursor moves one column to the right and the end of a logical screen line (after 80 characters) is automatically set the Return character = CHR$(13).

Examples[edit | edit source]

10 REM COPYING 255 SCREEN CHARACTERS TO A STRING VARIABLE
20 PRINT CHR$(19);: B$="": OPEN 1,3
30 GET#1,A$: B$=B$+A$: IF LEN(B$)<255 THEN 30
40 CLOSE 1
50 PRINT CHR$(147);B$
BASIC V2.0 (second release) Commands

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