Reading A Relative Record - Commodore 1551 User Manual

Table of Contents

Advertisement

overwrites any remaining spaces in the record. Thus, if you must use the offset option,
never update any field in a record other than the last one unless all succeeding fields will
also be updated from memory later.
The above programs are careful to match record lengths exactly to the. space
available. Programs that don't do so will discover that DOS pads short records out to full
size with fill characters, and truncates overlong records to fill only their allotted space.
When a record is truncated, DOS will indicate error 51, "RECORD OVERFLOW", but
short records will be accepted without a DOS error messagc.
READING A RELATIVE RECORD
Once a relative record has been written properly to diskette, reading it back into
computer memory is fairly simple, but the procedure again varies, depending on whether
it uses fixed or variable length fields. Here are the program lines needed to read back the
variable fields created above from record number RE in file and channel 3:
10 OPENI5,8,15
20 OPEN3,8,3, "O:MYRELFILE,L," + CHR$(88)
30 INPUT"ENTER RECORD NUMBER";RE
40 RH = INT(RE/256)
50 RL = RE - 256*RH
60 PRINT# 15, "P" + CHR$(96 + 3) +CHR$(RL)
+ CHR$(RH) + CHR$( 1)
70 GOSUBlOOO
80 INPUT#3, NA$,SA$,CS$,ZP$
90 GOSUB1000
100 PRINT#15,"P" +CHR$(96.3) +CHR$(RL)
+ CHR$(RH) + CHR$( I)
110 GOSUB 1000
120 PRINTNA$:PRINTSA$
130 PRINTCS$:PRINTZP$
140 CLOSE3:CLOSEI5:END
lOOOIFDS<20THENRETURN
1010 PRINTDS$:CLOSE3:CLOSEI5:END
READY.
Open the command channel.
Open the relative file
"myrelfile". Record length is 88.
Select and calculate
record number.
Position to start of record # RE
and check for errors.
Input the data and check
for errors.
Reposition for safety.
Print the record on screen.
Close and end.
Error checking subroutine.
Here are the lines needed to read back the version with fixed length fields:
10 OPENI5,8,15
20 OPEN3,8,3, "O:MYRELFlLE,L," + CHR$(88)
30 INPUT"ENTER RECORD NUMBER";RE
40 RH = INT(RE/256)
50 RL=RE-256*RH
53
Open command channel.
Open the relative file called
"myrelfile" The record length is
88.
Select and calculate record #.

Advertisement

Table of Contents
loading

Table of Contents