WRITE (XFILE)


9.0D

 

The WRITE instruction outputs information to an XFILE from data variables. The statement format is as follows:

 

[label]

WRITE

{xfile},{record};[[[{field}=]{var}]|[{rs}=]{xfile}]|[{listctl}]:

[,[[{field}=]{var}]|[{rs}=]{xfile}]|[{listctl}..]:

[;]

 

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:

  1. 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.

  2. 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:

  3.  

    Value

    Action

    -1

    Sequential forward processing

    -2

    Sequential forward processing

    -3

    Position to End Of File (EOF) prior to processing

    -4

    Sequential backward processing

     

  1. {field} is an identifier for the field to be written by the {var} variable. The syntax for {field} can be one of the following:

  2.  

    field name

    $field name

    @{svar} where {svar} is a variable that contains the field name

     

  1. If a $ precedes the field name, the $ character is stripped off and the field name references an attribute field.

  2. If no $ character precedes the field name, the field name references an element field or an attribute field.

  3. If no {field} is specified, the name of the {var} variable is the field name.

  4. {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:

  5.  

    record set name

    @{svar} where {svar} is a variable that contains the record set name

     

  1. If no {rs} is specified, the variable name associated with the {xfile} variable is the recordset name.

  2. 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.

  3. The supported {listctl} controls are as follows:

  4.  

    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

     

  1. If a record already exists at the position written, the record is replaced.

  2. 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:

 

X

XFILE

 

 

PREP

X,"NAME","Month1Liabilities",RECORDSET="LiabilityAmount"

 

WRITE

X,SEQ;$liabilityDay="1",Record_Text="5.14"

 

WRITE

X,SEQ;$liabilityDay="2",Record_Text="6.10"

 

CLOSE

X

Expected Output:

 

<Month1Liabilities>

  <LiabilityAmount liabilityDay="1">5.14</LiabilityAmount>

  <LiabilityAmount liabilityDay="2">6.10</LiabilityAmount>

<Month1Liabilities>

 

 

See Also: XML Support



PL/B Language Reference UPDATE (XFILE)