EasyManua.ls Logo

Commodore 1570 - Page 59

Commodore 1570
132 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
DEMONSTRATION
OF
SEQUENTIAL
FILES
(BASIC 2.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$(13)
160 OPEN 15,8,15
170 PRINT CHR$(147):REM CLEAR
SCREEN
190 PRINT
"** WRITE A FILE **"
210 PRINT
220 OPEN 2,8,2, "@O:SEQ FILE,S,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 CLOSE 2
340 PRINT
"** READ SAME FILE
BACK
**"
360 PRINT
370 OPEN 2,8,2, "O:SEQ FILE,S,R"
380 GOSUB 500
390 INPUT#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 CLOSE 2
455 CLOSE
15
460 END
480 REM
**
ERROR CHECK SIR
**
500 INPUT#15,EN,EM$,ET,ES
510 IF EN>O THEN PRINT
EN
,EM$,ET ,ES :STOP
520 RETURN
51
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
A Basic 3.5-only version could
replace line 500 with
500 IF DS>O THEN PRINT
DS$:STOP
and delete line 510

Related product manuals