ProvideX V8.20 > Language Reference > 2. Directives
381
WRITE Directive
             Add/Update Data in File
Formats
1. Write: WRITE (chan[,fileopt])varlist
2. Write Lock: WRITE LOCK (chan[,fileopt])varlist
Where:
chan
Channel or logical file number of the file to which to write.
Supported file options (see also, File Options, p.808):
fileopt
BSY=stmtref Traps Error #0: Record/file busy
DOM=stmtref Missing record transfer
END=stmtref END-OF-FILE transfer
ERR=stmtref Error transfer
IND=num Record index
KEY=num Record key (see Automatic Padding with KEY=Option)
REC=name$ Record prefix (REC=VIS(string$) can also be used)
RTY=num Number of retries (one second intervals)
TIM=num Maximum time-out (support write operations for TCP channels)
stmtref
Program line number or label to transfer control to.
Comma-separated list of variables, literals, and IOL= options.
varlist
Description
Use the WRITE directive to add/update a record to a file (logical file number /
channel). ProvideX also supports use of the WRITE directive with *MEMORY* (a
memory-resident file or queue of records.
Automatic Padding with KEY=Option
When you use KEY=string$:string$[:string$][...] ProvideX automatically pads key
segments. This is valid only if you have Keyed files with segmented key definitions.
ProvideX right-pads the key segment using $00$ (nulls) to the segment's full length.
The last segment in a compound key is not padded; e.g.,
KEYED "TEST", [1:1:5]+[2:1:6]+[3:1:8]
READ (1,KEY=A$:B$:C$)
is the same as
READ (1,KEY=PAD(A$,5,$00$)+PAD(B$,6,$00$)+C$)
Format 1: Write
WRITE (chan[,fileopt])varlist
If the specific record already exists (indexed, direct, or sort files) and you include the
DOM=stmtref option, control transfers to the stmtref. Otherwise, the specified
record is updated.