EasyManuals Logo

Sinclair ZX81 User Manual

Sinclair ZX81
92 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #25 background imageLoading...
Page #25 background image
200
GOTO
200
RUN
200
This looks all set to go on for ever unless you pull the plug out; but there is a less drastic remedy. Press
the
SPACE
key, which has 'BREAK' written above it. The program will stop, saying D/200.
At the end of every program line, the computer looks to see if this key is pressed; & if it is, then it stops.
The
BREAK
key can also be used when you are in the middle of using the tape recorder or the printer.
You have now seen the statements
PRINT
,
LET
,
INPUT
,
RUN
,
LIST
,
GOTO
,
CONT
,
CLEAR
,
NEW
&
REM
, & most of them can be used either as commands or as program lines - this is true of almost all
statements in BASIC. The only real exception is
INPUT
, which cannot be used as a command (you get
report 8 if you try; the reason is that the same area inside the computer is used for both commands & for
input data, & for an
INPUT
command there would be a muddle).
RUN
,
LIST
,
CONT
,
CLEAR
&
NEW
are
not usually much use in a program, but they can be used.
Summary
Statements:
GOTO
,
CONT
,
INPUT
,
NEW
,
REM
,
PRINT
STOP
in input data
BREAK
Exercises
1. In the square root program, try replacing line 40 by
GOTO
5,
GOTO
10 or
GOTO
15 - it should make no
perceptable difference to the running of the program. If the line number in a
GOTO
statement refers to a
non-existent line, then the jump is to the next line after. The same goes for
RUN
; in fact
RUN
on its own
actually means
RUN
0.
2. Run the string length program, & when it asks you for input type
X$ (after removing the quotes)
Of course, X$ is an undefined variable & you get report 2/110.
If you now type
LET
X$="SOMETHING DEFINITE"
(which has its own report of 0/0) &
CONT
you will find that you can use X$ as input data without any trouble.
The point about this exercise is that
CONT
has the effect of
GOTO
110. It disregards the report 0/0
because that had code 0, & takes its line number from the previous report, 2/110. This is intended to be
useful. If a program stops over some error then you can do all sorts of things to fix it, &
CONT
will start
work afterwards.
3. Try this program:
10
INPUT
A$
20
PRINT
A$;" = ";
VAL
A$
30
GOTO
10
(c.f. chapter 7, exercise 1).
Put in extra print statements so that the computer announces what it is going to do, & asks for the input
string with extravagant politeness.
4. Write a program to input prices & print out the VAT due (at 15%). Again, put in
PRINT
statements so that
it tells you what it's doing. Modify the program so that you can also input the VAT rate (to allow for zero
rating or future budgets).
5. Write a program to print a running total of numbers you input. (Suggestion: have two variables TOTAL -

Other manuals for Sinclair ZX81

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair ZX81 and is the answer not in the manual?

Sinclair ZX81 Specifications

General IconGeneral
ProcessorZilog Z80A
Processor Speed3.25 MHz
ROM8 KB
InputMembrane keyboard
StorageCassette tape
Power Supply9V DC
Dimensions167 mm x 40 mm x 175 mm
Release Year1981
ManufacturerSinclair Research
Weight350 g
Operating SystemSinclair BASIC
RAM1 KB
PortsTV out, expansion port
DisplayTelevision (RF modulator output)

Related product manuals