INPUT

From C64-Wiki
Jump to navigationJump to search
Disambiguation The title of this article is ambiguous. INPUT (Disambiguation).
BASIC keyword
Keyword: INPUT
Abbreviation: -
Type: Command
Token code: 133/$85
Handling routine
in BASIC ROM:
43967–44037
$ABBF–AC05
List of all BASIC keywords


Remark: This article describes the BASIC command INPUT in BASIC V2 at the Commodore 64.

Type: Command
General Programming-Syntax: INPUT ["<text/string>";]<Variable>[,<Variable>...]

The BASIC command INPUT is used to read data from the keyboard into one or more supplied variables. The INPUT command prints the optional text followed by a question mark (?) and then activates the screen editor for user input. User-entered data is stored in the supplied variables (which can be of type string, floating point or integer) after the user presses the RETURN . An extra question mark printed after RETURN  is pressed, means the INPUT command is waiting for additional data of the given variables. The data is separated by commas for more than one input variable. If additional data is entered beyond the required variables, the BASIC error "?EXTRA IGNORED" will be showed. Any extra data is not stored. If the user presses RETURN  without providing any data, the contents of the variables remains unchanged.

If the user supplies data that doesn't match the type of the supplied variables (for example, by providing a text with letters for an integer variable) the BASIC error "?REDO FROM START" will be displayed which means that the data has to be entered again. To avoid this type of error, it is recommended to use string variables for all data types. In direct mode INPUT results in the BASIC error "?ILLEGAL DIRECT ERROR".

Examples[edit | edit source]

10 INPUT "First input, please "; A$
20 INPUT "Only numbers (2-times) "; A1, A2%
40 PRINT: PRINT "Your input was: " A$, A1, A2%
50 PRINT: PRINT "Once again 3 numbers ";
60 INPUT A1%, B, Z
70 PRINT: PRINT "At last 3 inputs ";
80 INPUT A$, B$, C$
90 PRINT: PRINT "Your last input was: "; A1%, B, Z, A%, B$, C$

Trivia[edit | edit source]

  • Using POKE 19,1 (zeropage, current input file number) will omit the output of the "?" and RETURN , until reset with POKE 19,0. In this state the program aborts with message "?FILE DATA ERROR" rather than continuing with the warning message "?REDO FROM START".


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