ProvideX V8.20 > Language Reference > 2. Directives
88
DIRECT Directive
              Create File with Keyed Access
Format
DIRECT filename$,max_len[,max_recs[,rec_size]][,ERR=stmtref]
Where:
Filename of the DIRECT (Keyed) file. String expression. Mandatory.
filename$
max_len
Maximum length of the key for all records in the file. Mandatory.
Numeric expression, integer.
max_recs
Maximum number of records in the file. Optional numeric
expression. The default is zero (no limit). (Use a comma with no
value to set the default.)
If a positive value is supplied, ProvideX creates and pre-allocates
disk space for the file. With a negative value, ProvideX allocates
sufficient disk space for the file, but will set the max_recs count back
to zero (unlimited).
rec_size
Maximum size of the data portion of each record (excluding the key).
Optional. Numeric expression. You can use:
No Value: Default is VLR with maximum size of 256.
Positive Integer: FLR of size specified.
Negative Integer: VLR with maximum length specified.
stmtref
Program line number or label to transfer control to.
Description
Use the DIRECT directive to create a Direct file with an external key field. ProvideX
considers a Direct file to be the same as a Keyed file with an external key. If you use a
filename that already exists, ProvideX returns an Error #12: File does not
exist (or already exists). The maximum size of the key to the file is
mandatory along with the filename. The file type can be controlled by setting the
'KF'= System Parameter, p.668.
You can limit the number of records by specifying a maximum (an integer other than
zero). If you do attempt to set a maximum, then attempt to exceed this value (e.g., on
a WRITE statement) an Error #2 is generated. You can use zero (0) to create a
dynamic file, limited by physical file size limits and the amount of available drive
space.
If you include the maximum data length, it must be long enough to hold the
combined length of all the data fields and field separators for each record written to
the file.
WindX supports the use of this directive via the [WDX] tag; e.g., DIRECT
"[WDX]somefile.ext"... See [WDX] Direct Action to Client Machine, p.797.
See Also
CREATE TABLE Create Keyed File (EFF), p.57
KEYED Create Single/Multi-Keyed File, p.165
File Types, User's Guide