INPUT

Syntax:

input <string pointer destination>, <byte max_length> [,<string mask>]

The INPUT command calls a built-in routine that allows the user to input a string using the keyboard. The user input will be limited to max_length characters. After the user has pressed the RETURN key, the input will be copied to the string pointed by destination.

  • If the mask argument is provided, the user will be limited to enter characters that are present in the mask.
  • If no mask is provided, the default mask will be applied, which is PETSCII chars $20-$5F, $A0-$DF and $FF, inclusive. This means that only alphanumeric chars, signs and graphic symbols are allowed, control characters are disallowed. Please refer to the PETSCII table for more information

No prompt string (e. g. ? in CBM BASIC) is displayed. Line editing features are limited to the DELETE button, moving the cursor is not allowed.

Warning: the buffer that the string pointer points to must be wide enough to accept the user input, otherwise buffer overflow will occur!

Examples:

rem -- initialize a buffer first
dim buff![21]
name$ = @buff!
rem -- input any string, max 20 chars and store it to name$
input name$, 20

rem -- input a numeric string, max 6 chars
rem -- assume a buffer has been initialized
input num$, 6, "0123456789-"

rem --input a string, allowing alphanumeric chars only
rem -- assume a buffer has been initialized
input a$, 10, "0123456789abcdefghijklmnopqrstuvwxzy"

Note: to convert a string to a numeric type, use the VAL() function.

This command has been completely rewritten since version 2.0 and is incompatible with that of version 1.x.