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 #55 background imageLoading...
Page #55 background image
10
IF INKEY$<>
""
THEN GOTO
10
20
IF INKEY$
=""
THEN GOTO
20
30
LET
A$=
INKEY$
40
IF
A$=
CHR$
115
THEN GOTO
110
90
PRINT
A$;
100
GOTO
10
110
PRINT
" ";
120
GOTO
10
Note how we read
INKEY$
into A$ in line 30. It would be possible to miss this out & replace A$ by
INKEY$
in lines 40 & 0, but there would always be a chance that
INKEY$
could change between the lines.
Add some more programs so that if you type
NEWLINE
(
CHR$
118) it gives you a new line.
3. Another way of using
INKEY$
is in conjunction with
PAUSE
, as in this alternative typewriter program.
10
PAUSE
40000
20
POKE
16437,255
30
PRINT INKEY$
40
GOTO
10
To make this work, why is it essential that a pause should not finish if it finds you already pressing a key
when it starts?
This method has the disadvantage that the screen flashes, but in fast mode it is the only way of doing it.
Run the program in fast mode, & notice that the computer takes the opportunity of a pause to display the
television picture.
4. This one will drive you mad. The computer displays a number, which you (or an innocent victim) shall
type back. To begin with you have a second to do it in, but if you get it wrong you get a longer time for the
next number, while if you get it right you get less time for the next one. The idea is to get it going as fast as
possible, & then press Q to see your score - the higher the better.
10
LET
T=50
15
REM
T=NUMBER OF FRAMES PER GO-INITIALLY 50 FOR 1 SECOND
20
SCROLL
30
LET
A$=
CHR$ INT
(
RND
*10+
CODE
"0")
35
REM
A$ IS A RANDOM DIGIT
40
PRINT
A$
45
PAUSE
T
50
POKE
16437,255
60
LET
B$=
INKEY$
70
IF
B$="Q"
THEN GOTO
200
80
IF
A$=B$
THEN GOTO
150
90
PRINT
"NO GOOD"
100
LET
T=T*1.1
110
GOTO
20
150
PRINT
"OK"
160
LET
T=T*0.9
170
GOTO
20
200
SCROLL
210
PRINT
"YOUR SCORE IS ";
INT
(500/T)
5. (Only for those with extra RAM.) Using the straight line routine in chapter 15, change the second hand
program so that it also shows minute & hour hands, drawing them every minute. (Make the hour hand
shorter.) If you're feeling ambitious, arrange so that every quater of an hour it puts on some kind of a show.
6. (For fun.) Try this:
10
IF INKEY$
= ""
THEN GOTO
10
20
PRINT AT
11.14; "OUCH"
30
IF INKEY$<>
""
THEN GOTO
30

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