| Special File Handling |
|
| Input/Output Lists | In
order to simplify and reduce coding, all Input/Output
directives allow the use of common parameter lists called
IOLISTs. An IOLIST is a statement that consists of a list
of parameters to be used in an Input/Output directive. To reference an IOLIST the programmer includes the 'IOL=nnnn' option either as the parameter list or within a parameter list of an Input/Output directive. The value of 'nnnn' must be the line number or label of a statement which consists of the IOLIST directive followed by the parameters to be used or a string containing either a compiled object of an IOLIST statement or the name of an IOLIST for the file when the file contains multiple record formats. An Input/Output directive or IOLIST may contain as many IOL= options as desired. Example:
In the above example both the read and the write statements use the same IOLIST assuring that the same record contents are written as were read. |
||||||||||||||||||||||||||
| Defining IOLISTS on OPEN | Another
method to reduce the requirements of providing IOLISTs on
file Input/Output statements is to provide the IOLIST
with the file OPEN directive. If you include the option
IOL= within the OPEN statement, all further READ or WRITE
statements (which do not specify any form of IOLIST) will
automatically use the one given in the OPEN. For Example:
The READ statement at line 0340 and the WRITE statement at line 0500 both will utilize the IOLIST at line 1000. One major advantage of this technique is that as long as the file remains open, all subsequent READ or WRITE statements will use the IOLIST at 1000 even if they are executed from different programs thus passing just the channel number of an open file, can effectively pass its associated IOLIST. |
||||||||||||||||||||||||||
| Variable IOLISTs | ProvideX
also allows you pass IOLISTs as variables and use
variables as IOLISTS. In order to utilize a variable as
an IOLIST, it must first be initialized with the object
code for the desired IOLIST. This can be accomplished via
the CPL or PGM functions. Example:
NOTE: |
||||||||||||||||||||||||||
| *Note* | Due
to the fact that a RENUMBER directive could change the
line number of the IOLIST in the above example, we
suggest you use one of the following two pieces of logic:
|
||||||||||||||||||||||||||
| Once
a variable has been loaded with the IOLIST, it may be
specified following the IOL= option rather than a line
number or statement name. For Example:
|
|||||||||||||||||||||||||||
| * TIP * | One
of the easiest ways to handle IOLISTs is to assign them
during initialization to Global variables. For example:
This will allow you to easily change IOLISTs without having to make large scale program changes. If desired you could even open the files and assign them Global file numbers. |
||||||||||||||||||||||||||
| Formatted IOLISTS | In
addition to simply naming the variables which are to be
used in a READ of WRITE directive, an IOLIST can also
define the exact Format of a data record. A format
specification may be given immediately following the
variable names on a IOLIST directive. The Format
specification is used to define the exact size and form
that the data has on the file record. Format specifications should be separated from the variable name by a colon and enclosed within square brackets []. The following table defines the currently supported format specifications:
Where:
For Example:
In Line 1000 above, the IOLIST would be used for a 60 character record, with the field NAME in positions 1-30 and ADDR1 in positions 31-60. No delimiter would exist between the fields. In Line 1010 above, the IOLIST would be used against a comma delimited file where the string values would be enclosed in quotes. |
||||||||||||||||||||||||||
| *Note* | Normal unformatted output is equivalent to a format of CHR(SEP). | ||||||||||||||||||||||||||
| When
using the NUM, SGN, BIN, INT, and BCD format specifiers,
the scl parameter is used to define the scaling
factor to be applied to the numeric data. It represents
the number of implied decimal places that are to exist in
the number as it resides on the file. Example:
|
|||||||||||||||||||||||||||
| Prefixing via REC= | Sometimes
when using common IOLISTs it is desirable to temporarily
override the variable names in the IOLIST. The REC=
option provides this capability. When this option is
specified, the variable name which is provided (following
the REC=) is used to prefix all the variables in the
IOLIST. Example:
In the above example, the REC= option is used to maintain two separate records in memory. One record will have all its variables prefixed with 'DB.' , the other will have 'CR.' prefixes. |
||||||||||||||||||||||||||
| *Note* | The REC= option may also appear in the OPEN directive. | ||||||||||||||||||||||||||
| Data Dictionary IOLIST | ProvideX
includes several facilities for building and accessing a
data dictionary. While the data dictionary itself has
multiple uses from rapid application development to the
conversion of data; one of its main features is the
ability to embed the dictionary into data files and
thereby allow the system to generate IOLISTs
automatically. When the definition is embedded in the physical data file, the need for an IOLIST statement in your database application is rendered obsolete. An IOList reference is not required for a READ or WRITE statement. For example, the usual method for reading data from a data file without an embedded definition would appear as follows:
or
If a data dictionary definition is embedded in the physical file, the same routine could be handled as follows:
The IOL=* option defines a standard IOList to be used while the file is open and the asterisk indicates that the system is to use the IOLIST embedded within the file itself.. You can also use the REC= option to supply a prefix to be added to all the variables in the IOL=. For example in:
The asterisk itself is used to indicate the use of the the embedded definition. Optionally you can use a caret to open a file using analternate IOList. The following program illustrates how to open a file and read its contents using an embedded definition.
|
||||||||||||||||||||||||||
| Multiple Record Formats | The
data dictionary system also supports multiple-format
files, such as those with header and detail records.
These are often referred to as variant records. The
ability to define non-normalized data files is provided
within the data dictionary maintence facility and access
to the multiple formats is supported by PxPlus.
To access the various formats embedded within a data file, the IOL= option has been extended to allow the programmer to specify the name of the format to use. For example, assuming a file contains two formats "Header" and "Detail":
This will open the data file and assign the default IOLIST to the format named "Detail". All subsequent READ/WRITE requests that do not specify the data format will use the format as defined by "Detail". To override the format, the programmer may specifiy the name of the format as follows:
Named formats may also be accessed in the IOL( ) function as in:
This function will return the internally 'compiled' IOLIST that matches the format specified. The FIN ( ) function with a "FORMATS" specificaion can be used to obtain a comma seperated list of valid formats for an opened file. |
||||||||||||||||||||||||||
| *Note* | An Error # 81:Invalid IOLIST specification will be generated if a named format requested does exist on the file. | ||||||||||||||||||||||||||