Sinclair QL Beginner's Manual page 117

Hide thumbs Also See for QL:
Table of Contents

Advertisement

150 END FOR num
160 CLOSE #6
Suppose that you wish to set up a simple file of names and telephone numbers.
RON
678462
GEOFF
896487
ZOE
249386
BEN
584621
MEG
482349
CATH
438975
WENDY
982387
The following program will do it.
100 REMark Phone numbers
110 OPEN NEW #6,mdv1_phone
120 FOR record = 1 TO 7
130
INPUT name$,num$
140
PRINT #6;name$;num$
150 END FOR record
160 CLOSE #6
Type RUN and enter a name followed by the ENTER key and a number followed by the ENTER key.
Repeat this seven times.
Notice that the data is 'buffered'. It is stored internally until the system is ready to transfer a batch to
the Microdrive. The Microdrive is only accessed once, as you can tell from looking and listening.
COPY A FILE
Once a file is established, it should be copied immediately as a back-up. To do this type:
COPY mdv1_phone TO mdv2_phone
READ A FILE
You need to be certain that the file exists in a correct form so you should read it back from a
Microdrive and display it on the screen. You can do this easily using:
COPY mdv2_phone TO scr
The output to the screen will not provide spaces automatically between the name and the number but
it will provide a 'newline' at the end of each record. The output will be:
RON678462
GEOFF896487
ZOE249386
BEN584621
MEG482349
CATH438975
WENDY982387
You can get a more controlled presentation of the data with the following program.
100 REMark Read Phone Numbers
110 OPEN_IN #5,mdv1_phone
120 FOR record = 1 TO 7
130
INPUT #5,rec$
140
PRINT,rec$

Advertisement

Table of Contents
loading

Table of Contents