
Likewise, if end wasn’t there in line 70, the program would continue to run, and carry out line 80.
The colon : before the word end separates it from the previous instruction. Colons : can be used to
enable you to put two or more instructions on one program line. We have also added line 5 to clear
the screen at the start of the program. We will do this from now on in the following programs to
make things look neater.
Other keywords associated with IF and THEN include ELSE, OR and GOTO. The use of these words
in the IF command will become clearer as you work through this guide.
Reset the computer by pressing [CTRL] [SHIFT] and [ESC] keys.
FOR TO NEXT
We will now show the use of the FOR, TO and NEXT commands. For this example we will show a
way the computer can print the 12 times table (1x12,2x12,3x12, etc) Type the following, note that the
* symbol means multiply.
5 cls [ENTER]
1 0 f o r a = 1 t o 2 0 [ E N T E R ]
2 0 p r i n t a ” * 1 2 = “ a * 1 2 [ E N T E R ]
30 next a[ENTER]
run [ENTER]
You will notice the columns look untidy, so type in:
5 c l s [ENTER]
10 for a = 1 to 9 [ENTER]
2 0 p r i n t a ” * 1 2 = “ a * 1 2 [ E N T E R ]
30 next a [ENTER]
4 0 f o r a = 1 0 t o 2 0 [ E N T E R ]
5 0 p r i n t a ” * 1 2 = “ a * 1 2 [ E N T E R ]
60 next a [ENTER]
run [ENTER]
Try this program for multiplication tables using other numbers. For example, if you wanted to see
the 17 times table, replace the number 12 in lines 20 and 50 with the number 17. Finally, reset the
computer using the [CTRL][SHIFT] and [ESC] keys. Note that it is possible to specify the value of
each step taken in the FOR TO NEXT command by use of the STEP command. For further
information, study the description of FOR in Chapter 8.
SIMPLE ARITHMETIC
Your CPC464 can be used as a calculator quite easily.
To understand this carry out the following examples. We will use the ? symbol instead of typing print
in this section. The answer will be printed as soon as the
[ENTER]
key is pressed.
Содержание CPC464
Страница 1: ......
Страница 32: ...or you can type 3e1 1e1 ENTER 300 2 3000x1000 Type 3e3 1e3 ENTER 3000000 3 3000x0 001 Type 3e3 1e 3 ENTER 3 ...
Страница 102: ...PRINT 10 AND 12 Results in 8 PRINT 10 AND 1000 Results in 8 again ...
Страница 118: ...TO DO DRAW THIS PAGE ...
Страница 219: ...actual value may be made to vary during the execution of a program ...
Страница 240: ...Text and WINDOW planner Mode 2 80 Columns ...
Страница 241: ......
Страница 245: ...Sound envelope Music planner sheet ...