next up previous contents
Next: More about printing Up: Programming Help Previous: Conditionals and loops

User input

To stop the execution of any program, press simultaneously tex2html_wrap1718 + tex2html_wrap1720 .

To have user supply a value for variable X, write INPUT "Real number=";X

Note: instruction INPUT stops the program. The user has to hit tex2html_wrap1722 for the program to continue.

To scan for the key pressed by the user without stopping the program, use INKEY$ function instead of INPUT. This allows the user to control the program by simple menu functions. For example, embed the following lines within DO ... LOOP and stop the program by pressing KeyQ.

Key$=INKEY$

SELECT CASE Key$

CASE "Q"

END 'stop the program

CASE "q"

END 'stop the program

CASE "?"

PRINT "Did you ask for help?"

CASE ELSE

BEEP

END SELECT

A simple way to let the user know that something went wrong is to BEEP.

Exercise892

Exercise894



Send comment