| Directives |
|
| Format | SERIAL
filename$[,max_recs[,rec_size]][,ERR=stmtref] Where:
|
||||||||||||||
| Description | When
you use the SERIAL directive to create a
serial (sequential or flat) file, ProvideX creates a
standard text data file in a format the operating system
can access directly. The record size is "for
documentation purposes only" on most operating
systems. If you do specify the size, make it large enough
to hold all the data fields written to the file for each
record. If a file of the name you use already exists,
ProvideX returns an Error #12: File does not exist (or
already exists). Record Access Mode and Binary Access Mode In record access mode, a serial file is read a line or record at a time. Each line is determined by the presence of end-of-line-character(s) which are different based on the OS. On UNIX (or similar OSs) the end-of-line character is the line feed ($0A$), on Microsoft Windows it is a carriage return followed by a line feed ($0D0A$). Each READ or READ RECORD will only read 1 line. When using a standard READ directive READ each line will be parsed by any field SEP's that exist within the line and the corresponding variables within the READ will be set. If you use a READ RECORD then the field SEP's will not be parsed and the variable on the directive will receive the complete lines data. When you OPEN a serial file in record access mode, there are 2 logical file pointers in the file. The read pointer starts at the top of the file, and the write pointer starts at the bottom; therefore, reads return the data starting from the first record whereas writes automatically append to the end of the file. You can move both file pointers by issuing a READ or WRITE and supplying an IND= clause (IND=0 is the first record, IND=1 is second, etc.) When a file is opened in binary access mode, you can read and write byte by byte with no regard for the data contents. The data on the file is logically parsed into records each of whose size is based on the ISZ= in an OPEN clause. For example,
This sets binary access mode with the contents of the file being considered a series of 1-byte records. An OPEN(chan,ISZ=512) sets binary mode with a series of 512-byte records. A READ or READ RECORD will read the ISZ= number of bytes and treat these as a record. Using an IND= moves the current file pointer to a specific record, so when using ISZ=1, the IND= will take you to a specific byte offset within the file. |
||||||||||||||
| Examples | Both
examples below create files whose structures are viewed
by ProvideX as serial (or
unknown type):
|
||||||||||||||
| *Note* | WindX supports the use of this directive via the [WDX] or ]LCL] tag in the file name; e.g., SERIAL "[LCL]somefile.ext". Versions 4.20 and earlier require you to encapsulate the command in an EXECUTE "[WDX]..." directive. See [WDX] Direct Action to Client Machine. | ||||||||||||||
| See Also | Labels/Logical Statement
References 'NN' System Parameter, LOAD Read Program into Memory, SAVE Write Program to File. |
||||||||||||||