EasyManua.ls Logo

Commodore 128 - Prompt Messages

Commodore 128
448 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 INPUTPLEASE 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.
Dont forget to use the $ to identify all your string variables. Clear
your computer’s memory by typing NEW and pressing RETURN.
Then type in this program.
10 INPUTWHAT IS YOUR NAME;N$
20 ? HELLO ;N$
Now RUN the program. When the computer prompts WHAT IS
YOUR NAME?, type your name. Dont 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$
<RETURN>your computer remembers your name!
4-8

Table of Contents

Other manuals for Commodore 128

Related product manuals