Directives
DIRECT Create File with Keyed Access
 
Format DIRECT filename$,max_len[,max_recs[,rec_size]][,ERR=stmtref]
 
Where:
 
filename$ Filename of the DIRECT (Keyed) file. String expression. Mandatory.
 
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 statement label to which to transfer control.
 
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.
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.


*Note* As of Version 4.20, WindX supports the use of this directive via the [WDX] tag; e.g., DIRECT "[WDX]somefile.ext"... If you are running an earlier version of ProvideX on a WindX PC, you still need to encapsulate the command in an EXECUTE


"[WDX]..." directive. See [WDX] Direct Action to Client Machine.
 
See Also CREATE TABLE Create Keyed File (EFF)
KEYED Create Single/Multi-Keyed File.
 
Examples 0110 DIRECT A$+"-"+B$,10,100,50,ERR=1090
0200 DIRECT "CSTFLE",6,0,-128
Line 0200creates a file with the following structure:
Keyed file: C:\MANUALS\PVX\CST\CSTFLE
Maximum Record size ..........: 128 (variable) Maximum # records ............: (No limit) Current # records ............: 0
Size of key block ............: 2048 bytes
External key size ............: 6