SERIAL Files

A SERIAL file is a sequence of varying length records. Like INDEXED files, the records are numbered starting with zero. When a SERIAL file is created it contains no records. As data is written to the file, records are added at the end of the file. The records are normally accessed sequentially but they may also be accessed randomly by record number. Random access may be slow.

Any data may be written to a SERIAL file. PRO/5 uses byte counts to determine the size of each record. The record size is saved at the start of each record. Because of this, PRO/5 must read each record in order to skip it. If you are skipping a limited number of records, or are accessing each record sequentially, this overhead is not particularly time consuming.

Any number of users may read a SERIAL file at one time; however, you must LOCK the file in order to write to it. SERIAL files are created with the SERIAL verb.

The EXTRACT command will not really lock the EXTRACTed record, it simply does not advance the pointer to the next record.

Any WRITE to a SERIAL file logically terminates the file at the written record. If a record is written to the middle of a SERIAL file, the file is logically truncated at that point. All existing records following the new record are no longer accessible.

Historically, SERIAL files were used for temporary storage of spooled output to printer systems. The "newer" string file is actually much more suitable for this purpose and SERIAL files are slowly being considered historic data structures.

A SERIAL file may contain records up to 32767 bytes in length and have as many as (2^31)-1 records. The SERIAL file may not contain more than (2^31)-1 bytes total.

The FIN() of a SERIAL file returns the following information:

Bytes

Contents

65,4

Next available file index

69,4

Number of bytes in file, including the header

73,2

Number of bytes in the last record

75,2

"s"+$01$

See Also

SERIAL Verb