Commodore 1551 User Manual page 50

Table of Contents

Advertisement

If an overlong string has managed to be recorded in a file, it may be safely read back
into the computer with Get#, using a loop such as this
3300 B$= ""
3310 GET#I,A$
3320 IF A$<>CHR$(13) THEN B$ = B$
+
A$:GOTO 3310
The limit for such a technique is 255 characters. It will ignore CHR$(O), but that may be
an advantage in building a text string.
Get# may be especially useful in recovering damaged files, or files with unknown
contents. The Basic reserved variable ST (the file STatus variable) can
be
used to indicate
when all of a properly-closed file has been read.
500 GET#2,S$
510 SU=ST:REM REMEMBER FILE STATUS
520 PRINT
S$;
530 IF SU =0 THEN 500:REM IF THERE'S MORE TO BE READ
540 IF SU<>64 THEN PRINT "STATUS ERROR: ST = ";SU
Copying ST into SU is often an unneccessary precaution, but must be done if any other
file-handling statement appears between the one which read from the file and the one that
loops back to read again. For example, it would be required if line 520 was changed to
520 PRINT# 1
,S$;
Otherwise, the file status checked in line 530 would be that of the write file, not the read
file.
POSSIBLE VALUES OF THE FILE STATUS VARIABLE "ST",
AND THEIR MEANINGS
IFST=
o
All is OK
THEN
1
Receiving device was not available (time out on talker)
2
Transmitting device was not available (time out on listener)
4
Cassette data file block was too short
8
Cassette data file block was too long
16
Unrecoverable read error from cassette, verify error
32
Cassette checksum error--one or more faulty characters were read
64
End of file reached (EQ[ detected)
128
Device not present, or end of tape mark found on cassette
42

Advertisement

Table of Contents
loading

Table of Contents