ProvideX V8.20 > Language Reference > 2. Directives
382
Examples:
0410 WRITE (1,ERR=1000,DOM=1200)A,B,Z9$
An IND=index clause is mandatory if you are writing to an indexed file; e.g.,
0810
LET I=0
0820
OPEN (8)"PVX_INDX"
0830
READ (8)IOL=110,ERR=0950
0840
LET I=I+1 ! This reserves an empty record at index 0
0850
CALL "SOMETHING",IOL=0110,ERR=950
0900
WRITE (8,IND=I,ERR=9000)IOL=0110
0910
GOTO 0830
The KEY=num is mandatory if you are writing to a Keyed file with an external key or
to a DIRECT or SORT file; e.g.,
0710 OPEN (7)"PVX_SORT"
0720 READ (6)CUST$,NAME$,*,*,*,*,*,*,*,*,*,ERR=0750
0730 WRITE (7,KEY=CUST$)
No KEY= option is allowed if you are writing to a Keyed file whose primary key is
composed of data fields embedded in the record data. In Keyed files with multiple
keys, the WRITE directive will automatically update all alternate keys. For instance,
alternate keys 0 [1:1:6] and 1 [2:1:10] are updated as follows:
KEYED "PVX_KEYD",[1:1:6],[2:1:10],,256
0210 OPEN (2)"PVX_KEYD"
0220 READ (6)CUST$,NAME$,*,*,*,*,*,START_DT$,CRED_LIM,TERMS,END_DT$,ERR=0250
0230 WRITE (2)IOL=0100
ProvideX uses the variables in the variable list either in delimited form or in
accordance with any format specified (with headers, etc.). The contents of these
fields are used to generate the actual data record. Numeric data converted during a
WRITE directive does not use the 'DP' Decimal Point Symbol or 'TH' Thousands
Separator system parameters for European decimal settings.
The list of variables can refer to an IOList (using IOL=iolref) as above. The iolref can be
the line number or label of the line containing the IOList, or it can be a string
containing a compiled IOList. If you omit the list of variables from the WRITE
directive, ProvideX uses the IOL specified (if any) on your OPEN statement for the file.
Writing to *MEMORY*
A WRITE operation will check the last entry in the key table for the key being added
before proceeding to the top of the key chain to determine the new entry point. This
dramatically increases the speed of writing additional records in sequential order.
You can use WRITE and/or WRITE RECORD directives to update records in a
Memory file using an IOList or a string expression. Records may be inserted by
index at a given index number. If the index does not already exist, the record will be
automatically appended at the last unused index.