User input/Text: Difference between revisions

Content added Content deleted
(Added Commodore BASIC)
Line 440: Line 440:
<lang basic>10 INPUT "ENTER A STRING: "; S$
<lang basic>10 INPUT "ENTER A STRING: "; S$
20 INPUT "ENTER A NUMBER: "; I : I = INT(I)</lang>
20 INPUT "ENTER A NUMBER: "; I : I = INT(I)</lang>

==={{header|Commodore BASIC}}===
When using the prompt feature of the <code>INPUT</code> command, the string literal must be followed by a semicolon and then the string variable, or else a <code>?SYNTAX ERROR</code> will occur. The question mark prompt is always presented with the <code>INPUT</code> command. Any other behavior would have to come from a user-built routine using the <code>GET</code> command.

Also, when a numeric variable is provided for input, the computer will make repeated attempts to obtain valid input from the user until the input can be clearly interpreted as a numeric value.

<lang gwbasic>
10 input "what is a word i should remember";a$
20 print "thank you."
30 input "will you please type the number 75000";nn
40 if nn<>75000 then print "i'm sorry, that's not right.":goto 30
50 print "thank you." print "you provided the following values:"
60 print a$
70 print nn
80 end
</lang>

'''Output'''
<pre>
READY.
RUN
WHAT IS A WORD I SHOULD REMEMBER? PANCAKE
THANK YOU.
WILL YOU PLEASE TYPE THE NUMBER 75000? NO.
?REDO FROM START
WILL YOU PLEASE TYPE THE NUMBER 75000? 848
I'M SORRY, THAT'S NOT RIGHT.
WILL YOU PLEASE TYPE THE NUMBER 75000? 75000
THANK YOU.
YOU PROVIDED THE FOLLOWING VALUES:
PANCAKE
75000

READY.
&#9608;
</pre>



==={{header|IS-BASIC}}===
==={{header|IS-BASIC}}===