DEMONSTRATION
OF
SEQUENTIAL
FILES
(BASIC 7.0)
Use the following program for your first experiments with sequential files.
Comments have been added to help you better understand it.
150 CR$ = CHR$(l3)
170 PRINT CHR$(l47):REM CLEAR
SCREEN
190 PRINT
"**
WRITE A FILE **"
210 PRINT
220 DOPEN
#2,
"@SEQFILE",W
230 GOSUB 500
240 PRINT"ENTER A WORD,
THEN A NUMBER"
250 PRINT"OR 'END,O' TO
STOP"
260 PRINT
270 INPUT A$,B
280 PRINT#2,A$;CR$;B
290 GOSUB 500
300 IF
A$<>"END"
THEN 270
310 PRINT
320 DCLOSE
#2
340 PRINT ,,** READ SAME FILE
BACK
**"
360 PRINT
370 DOPEN
#2,
"SEQ
FILE"
380 GOSUB 500
390INPUT#2,A$,B
400
RS=ST
410 GOSUB 500
420 PRINT A$,B
430 IF
RS
= 0 THEN 390
440
IF
RS<>64
THEN
PRINT"STATUS =
";RS
450 DCLOSE
#2
460 END
480 REM
**
ERROR CHECK SIR
**
500 IF DS>O THEN PRINT DS$:STOP
510 RETURN
52
Make a carriage return variable
Open demo
file
with replace
Check for disk errors
Accept a string
& number
from keyboard
Write them to the disk
file
Until finished
Tidy
up
Reopen same
file
for reading
Read next string
& number from file
Remember
file
status
Display
file
contents
until done,
unless there's
an
error
Then quit