WRITE (XFILE)
9.0D
The WRITE instruction outputs information to an XFILE from data variables. The statement format is as follows:
|
|
|
|
Where:
label
Optional. A Program Execution Label.
xfile
Required. A previously defined and opened XFILE variable to which data is written.
record
Required. A previously defined Numeric Variable, that selects the record to written.
field
Optional. The name of a field.
var
Optional. A previously defined Character String Variable, Numeric Variable, string or numeric ARRAY, or individual array element.
rs
Optional. The name of a recordset.
listctl
Optional. A supported list control.
;
Optional. indicates Partial I/O.
Flags Affected: NONE
Note the following:
If {record} is equal to or greater than zero, it designates a record in the record set for random access. The first record in the record set is zero (0) and each subsequent record increments the reference appropriately.
If {record} is a negative number equal to -1, -2, -3 or -4, it indicates sequential file processing (see Sequential Access Method). The differences are as follows:
|
Value |
Action |
|
-1 |
Sequential forward processing |
|
-2 |
Sequential forward processing |
|
-3 |
Position to End Of File (EOF) prior to processing |
|
-4 |
Sequential backward processing |
{field} is an identifier for the field to be written by the {var} variable. The syntax for {field} can be one of the following:
|
field name |
|
$field name |
|
@{svar} where {svar} is a variable that contains the field name |
If a $ precedes the field name, the $ character is stripped off and the field name references an attribute field.
If no $ character precedes the field name, the field name references an element field or an attribute field.
If no {field} is specified, the name of the {var} variable is the field name.
{rs} is an identifier for a recordset to associated with the referenced the {xfile} variable. The syntax for {rs} can be one of the following:
|
record set name |
|
@{svar} where {svar} is a variable that contains the record set name |
If no {rs} is specified, the variable name associated with the {xfile} variable is the recordset name.
When a recordset is associated with an XFILE during a WRITE, any previous association is cleared and a new association is created as if an OPEN operation has occurred.
The supported {listctl} controls are as follows:
|
Control |
Function |
|
*BLON |
All leading and trailing blank (white space) characters in a DIM data variable are written for a XML element. |
|
*BLOFF |
All leading and trailing blank (white space) characters in DIM data variables are removed before the data is written for a XML element. |
|
*LC |
Disable *UC (default) |
|
*LL |
Set the Length Pointer to last non-blank character |
|
*PL |
Disable *LL (default) |
|
*UC |
Convert lower-case data to upper-case |
|
*ZF |
Zero-fill numeric variables |
|
*ZS |
Blank-fill zero numeric variables |
If a record already exists at the position written, the record is replaced.
WRITE supports the 'Record_Text=' internal data tag reference. This allows a given XML tag to contain both an attribute and data. The 'Record_Text' tag is not case sensitive.
Example:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Expected Output:
<Month1Liabilities>
<LiabilityAmount liabilityDay="1">5.14</LiabilityAmount>
<LiabilityAmount liabilityDay="2">6.10</LiabilityAmount>
<Month1Liabilities>
See Also: XML Support
![]() |