omron — Advanced Disk Operations

Advanced Disk Operations Advanced Disk Operations This section introduces additional parameters to the FOPEN and FOPENR program instructions. For details, see the FOPEN and FOPENR documentation in the eV+ Language Reference Guide for details. Variable-Length Records The default disk file access mode is variable-length record mode. In this mode, records can have any length (up to a maximum of 512 bytes) and can cross the boundaries of 512-byte sectors. The end of a record is indicated by a Line-Feed character (ASCII 10). Also, the end of the file is indicated by the presence of a Ctrl+Z character (26 decimal) in the file.

Variable- length records should not contain any internal Line-Feed or Ctrl+Z characters as data. This format is used for loading and storing eV+ programs, and is compatible with the IBM PC standard ASCII file format. Variable-length record mode is selected by setting the record length parameter in the FOPEN_ instruction to zero, or by omitting the parameter completely. In this mode, WRITE instructions automatically append Return (ASCII 13) and Line-Feed characters to the output data-which makes it a complete record. If the /S format control is specified in an output specification, no Return/Line-Feed is appended.

Then any subsequent WRITE will have its data concatenated to the current data as part of the same record. If the /Cn format control is specified, n Return/Line-Feeds are written, creating multiple records with a single WRITE. When a variable-length record is read using a READ instruction, the Return/Line-Feed sequence at the end is removed before returning the data to the eV+ program. If the GETC function is used to read from a disk file, all characters are returned as they appear in the file- including Return, Line-Feed, and Ctrl+Z characters. Fixed-Length Records In fixed-length record mode, all records in the disk file have the same specific length.

Then there are no special characters embedded in the file to indicate where records begin or end. Records are contiguous and may freely cross the boundaries of 512-byte sectors. Fixed-length record mode is selected by setting the record length parameter in the FOPEN_ instruction to the size of the record, in bytes. WRITE instructions then pad data records with zero bytes or truncate records as necessary to make the record length the size specified. No other data bytes are appended, and the /S format control has no effect. In fixed-length mode, READ instructions always return records of the specified length.

If the length of the file is such that it cannot be divided into an even number of records, a READ of the last record will be padded with zero bytes to make it the correct length. Sequential-Access Files Normally, the records within a disk file are accessed in order from the beginning to the end without skipping any records. Such files are called sequential files. Sequential-access files eV+Language User's Guide, v2.x, 18318-000 Rev A Page 148