More Variables, And Strings - AMSTRAD CPC464 User Manual

Cpc464 colour personal computer 64k
Hide thumbs Also See for CPC464:
Table of Contents

Advertisement

Line 70 introduces a delay loop as the computer counts ' n' from 1 to 900 before executing the next
statement - G 0 T 0 5. Thus the program re-cycles itself without ending. The only way out is to
[ESC]ape using the [ESC] key provided. Pressing this once will stop execution of the program.
Pressing it again will BREAK out into the direct command mode, without losing the contents of the
program memory.
In fact, unless you press [ESC] while the computer is still looping through the delay on line 70, the
program will break immediately, since the computer isn' t executing anything when it is waiting for
an input. The line it was waiting on will be listed after the Break. If you escape while the computer
is waiting for input, you will get the message:
Break in 10
If you can catch it in the delay loop, the message after the second depression of the
key is:
[ESC]
Break in 70
If you escape during the loop on line 70, you will suspend operation, and this can be resumed where
it left off simply by pressing ' any key' . If you break out of the program, you can also resume where
you broke out by entering:
CONT
And the program will CONTinue from the line in which operation was suspended.
Whatever you do with the
key, you will not lose the program stored in current memory unless
[ESC]
you specifically instruct the computer to clear it out using a NEW command - or you issue a full reset
command by holding down the
and
keys simultaneously.
[CTRL] [SHIFT]
[ESC]
Thus there should be no need to provide a safety net for those who ' inadvertently' reset the machine.
The action of clearing out the current program memory is very deliberate, and very permanent. Save
anything on to the cassette if you are in any doubt whether you will want to use it again.

4.7 More variables, and strings

The essence of computing is the variable. If the computer is dealing strictly with fixed commodoties,
then it is merely an electronic typing aid. Remember that if any part of a mathematical expression is
variable, then the result must also be variable.
Variables have three attributes or characteristics: a name, a type and an ' organisation' . Names have
been discussed earlier (4.1) - types are optional, so we could define a variable according to the rules
of (3.4) as:
The type markers are: <name>[<type marker>]
% for integer numbers where anything to the right of a decimal point is discarded. Integer variables
occupy less space in memory, and so programs that do not require decimal manipulations can be
made to run faster if the variables are DEFined as integers. The command DEFINT indicates that
variable names without an implicit type marker are to be taken as integer variables. Following the
command DEFINT A therefore, the same variable could be called A% or A, both being integer.
Integer values range from -32768....+32767.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents