A file can be thought of as a one dimensional array located on a mass storage device. Various portions of the data can be accessed via a simple algorithm:
Row * Width + Column (provided that the result is not beyond the end of the file)
where: Row = a down position
Width = either an arbitrary length or a known length
Column = a position on Row
For example, portions of data stored using an 8 X 8 array can be extracted into a smaller array by:
My question:
How would one use a small two dimensional array to create a large random access file that emulates the above process? I've tried several different methods but with each I either get way too many records, too few records, overlaps, or gaps. The reason I'm trying to do this is so that I can access portions of up to four "areas" in the file and modify the records at the same time.
Visualization:
Row * Width + Column (provided that the result is not beyond the end of the file)
where: Row = a down position
Width = either an arbitrary length or a known length
Column = a position on Row
For example, portions of data stored using an 8 X 8 array can be extracted into a smaller array by:
Code:
Wide = 8 Row = 3 Column = 4 Col = Column FOR I = 1 TO 2 R1 = Row * Wide FOR J = 1 TO 3 Rec = R1 + Col GET #1, Rec, A(I, J) INCR Col NEXT J INCR Row Col = Column NEXT I
How would one use a small two dimensional array to create a large random access file that emulates the above process? I've tried several different methods but with each I either get way too many records, too few records, overlaps, or gaps. The reason I'm trying to do this is so that I can access portions of up to four "areas" in the file and modify the records at the same time.
Visualization:
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
------------------------
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
.....----- -----,,,,,,
.....----- -----,,,,,,
;;;;;----- -----:::::
;;;;;----- -----:::::
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
------------------------
.......... ,,,,,,,,,,
.......... ,,,,,,,,,,
.....----- -----,,,,,,
.....----- -----,,,,,,
;;;;;----- -----:::::
;;;;;----- -----:::::
;;;;;;;;;; :::::::::
;;;;;;;;;; :::::::::
Comment