The INPUT$ function reads a string of characters specified on the
keyboard and stores them in a variable. Unlike INPUT
, which pauses
and waits until the user presses wnter, INPUT$
reads a fixed
number
of characters without prompting for an enter.
It is used to read barcodes, serial numbers, or other fixed
character sequences, and to create simpler and more direct
user interfaces, avoiding the need to press enter after each
character.
INPUT$
always reads the specified number
of characters,
even if the user types fewer than that. It does not perform any
checks on the validity of the characters entered.
The INPUT
command allows you to ask the user to enter data, such as
numbers or text, while your program is running. When your program
encounters an INPUT
statement, it stops executing and displays
a prompt (usually the name of the variable) that invites the user
to enter a value. The user types the value and presses Enter.
The entered value is then stored in the specified variable.
Make sure the variable type matches the type of data you want
to capture (e.g. a numeric variable for a number, a string
variable for text). The message is optional but highly
recommended to make it clear to the user what to enter.
After entering the value, the user must always press Enter to confirm.
= INPUT$(number) INPUT [prompt];v1[;v2[;...] INPUT [prompt];v1[,v2[,...] INPUT [prompt],v1[;v2[;...] INPUT [prompt],v1[,v2[,...]
IF INPUT$(3) = "123" THEN PRINT "123 has been pressed!" ENDIF INPUT "Type a string ", a$ PRINT "The string was "; a$
Join BASIC 10Liner Contest with ugBASIC!
An interesting competition is held at the beginning of each year: the
BASIC 10Liner Contest.
It is possible to use ugBASIC to participate in the next
"BASIC10Liner" competition, in the following categories:
INPUT (function) ↔ Ip
If you have found a problem with this keyword, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO KEYWORDS