Disk File Input/Output |
Random File I/O
Random I/O requires a bit more care and coding than sequential I/O, but is more flexible because you can move back and forth within a disk file. These are the key differences:
•To get data from random disk files to
•Random 110 operations (GET and PUT) always read or write all 128 bytes of a floppy disk sector. You must specify how this
•Because all data in random files is treated as string data, you must convert strings that represent numbers into numeric values if you want to do any calculations with them.· Likewise, if you want to write a numeric value to a ran- dom file, you must first convert it to a string. Special functions are provided to do this.
•You must use special assignment statements to put a string variable into an 110 buffer. This is due to the fact that the fields you define in an I/O buffer are of
•Unless you simply want to read or write records in sequence, you .must specify which record you want to read or write.
1/0 Buffers
To emphasize: the usual variable and line delimiters (", CR) have no special mean- ing. All 128 bytes from the specified sector are placed in the 110 buffer. If fewer than 128 bytes were written to the sector, the remaining character positions in the buffer are set to ASCII blanks (hexadecimal 20) .
Defining a Random 1/0 Field-FIELD
When a sector has been read into the 110 buffer, it exists as a
The FIELD statement tells