The Value Of Index Files (Advanced Users) - Commodore 1551 User Manual

Table of Contents

Advertisement

60 PRINT# 15, "P" + CHR$(96 + 3) + CHR$(RL)
+ CHR(RH) + CHR$(l)
70 GOSUB 1000
80INPUT#3,DA$
90 GOSUBlOOO
100 PRINT#15, "P" +CHR$(96 + 3)+ CHR$(RL)
+ CHR$(RH) + CHR$( I)
110 GOSUB 1000
120 NA$= LEFf$(DA$,27)
130 SA$=MlD$(DA$,28,27)
140 CS$ = MlD$(DA$,55,23)
150 ZP$
=
RIGHT$(DA$, 10)
160 PRINTNA$:PRINTSA$
170 PRINTCS$:PRINTZP$
180 CLOSE3:CLOSEI5:END
1000 IFDS<20 THEN RETURN
1010 PRINTDS$:CLOSE3:CLOSEI5:END
READY.
Position to start of record
# RE and check for errors.
Input the record.
Reposition for safety.
Split the data into fields.
Print data on screen.
Close and end.
Error checking subroutine.
THE VALUE OF INDEX FILES (ADVANCED USERS)
In the last two chapters we have learned how to use sequential and relative files
separately. But they are often used together, with thc sequential file used to keep brief
records of which name in thc rclative file is stored in each record number. That way the
contents of the sequential fi Ic can be read into a string array and sorted alphabetically.
After sorting, a techniquc known as a binary search can be used to very quickly find an
entered name in the array, and read in or write the associated record in the relative file.
Advanced programs can maintain two or more such index files, sorted in differing ways
simultaneously.
54

Advertisement

Table of Contents
loading

Table of Contents