INPUT

From C64-Wiki
Jump to: navigation, 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 (type: string, floating point or integer) after the user presses the <RETURN>-key. If additional question marks are printed after the <RETURN>-key is pressed, it means the INPUT command is waiting for additional data for additional variables. 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 printed. 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 alpha text for an integer variable) the BASIC-error "?REDO FROM START" will be displayed. That means, that the data must be inputed over again. To avoid this type of error, use string variables for all data types. In direct-mode INPUT results in the BASIC-error "?ILLEGAL DIRECT ERROR".

Examples[edit]

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]

  • Using POKE 19,1 will disable printing the "?" and <RETURN>, until reset with POKE 19,0. In this state, it will give a bad data error rather than 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