Prompt Messages - Commodore 128 System Manual

Table of Contents

Advertisement

ln other words, you want to be able to change the value of the
variable K each time you run the program, without having to
change the program itself. We call this the ability to interact with
the computer. You can have the computer ask you how many
times you want it to execute the loop. To do this, use the INPUT
command. For example, replace line 10 in the program with:
10 INPUT K
Now when you RUN the program, the computer responds with a
? to let you know it is waiting for you to enter what you want the
value of K to be. Type 15 and press RETURN. The computer will
execute the loop 15 times.

Prompt messages

You can also make the computer print a message in an INPUT
statement to tell you what variable it's waiting for. Replace line 10
with:
10 INPUT" PLEASE ENTER A VALUE FOR K";K
Remember to enclose the message to be printed in quotes. This
message is called a prompt. Also, notice that you must use a
semicolon between the ending quote marks of the prompt and
the K. You may put any message you want in the prompt, but the
INPUT statement must be 160 characters or less, just as any
BASIC command must.
The INPUT statement can also be used with string variables. The
same rules that apply for numeric variables apply for strings.
Don't forget to use the $ to identify all your string variables. Clear
your com puter's memory by typing NEW and pressing RETURN.
Then type in this program.
10 INPUT" WHAT IS YOUR NAME";N$
20 ? " HELLO " ;N$
Now RUN the program. When the computer prompts " WHAT IS
YOUR NAME?" , type your name. Don't forget to press RETURN
after you type your name.
Once the value of a variable (numeric or string) has been
inserted into a program through the use of INPUT, you can refer
to it by its variable name any time in the program. Type ?N$
< R E T U R N > —your computer remembers your name!
4-8

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents