Input – Rockwell Automation 1771-DB BASIC MODULE User Manual
Page 169
Chapter
Statements
11
11 -17
Use the INPUT statement to enter data from the console device during
program execution. You may assign data to one or more variables with a
single input statement. You must separate the variables with commas.
You are prompted to enter data for each variable after the INPUT. If you
do not enter enough data, the module prints
TRY AGAIN
on the console
device.
>10 INPUT A,C
You can write the INPUT statement so that a descriptive prompt tells you
what to enter. The message printed is placed in quotes after the INPUT
statement. If a comma appears before the first variable on the input list,
the question mark prompt character is not displayed.
>10 INPUT “ENTER A NUMBER – ”,A
You can also assign strings with an INPUT statement. Strings are always
terminated with a carriage return (cr). If more than one string input is
requested with a single INPUT statement, the module prompts you with a
question mark. You can assign strings and variables with a single INPUT
statement.
>20 INPUT “NAME(CR),AGE – ”,$(1),A
Use the INPUT# statement to input data from port PRT2. Use the
INPUT@ statement to input data from port PRT1. Both these statements
function like the INPUT statement.
Syntax
INPUT
Example
>1 REM EXAMPLE PROGRAM
>10 INPUT A,C
>20 PRINT A,C
>RUN
?1
TRY AGAIN
?1,2
l 2
INPUT