Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 4
Format-Directed Formatting
The FORMATDATA[X] procedure takes the data items pointed to by the data
descriptors and formats them according to the internal format provided by the
FORMATCONVERT[X] procedure. FORMATDATA[X] places the output in the I/O
buffers.
The FORMATDATA[X] procedure reads the edit descriptors from left to right and
retrieves data descriptors from the top of the data descriptor list when required by the
edit descriptor. Note that while every data descriptor has a corresponding edit
descriptor, not every edit descriptor has a corresponding data descriptor. Some edit
descriptors, for example, provide tabulation information and therefore move a pointer
to a specific location without accessing any data.
Formatting Input
Figure 19-2 shows the role of the FORMATCONVERT[X] and FORMATDATA[X]
procedures in formatting input data according to a specified format.
For input formatting, bit 15 of the flags parameter supplied to the FORMATDATA[X]
procedure must be set to 1. Bit 2 is set to zero for format-directed formatting.
Again, the format is specified as a sequence of edit descriptors that you supply to the
FORMATCONVERT[X] procedure in external form. The FORMATCONVERT[X]
procedure converts the input string into an internal form suitable for passing to the
FORMATDATA[X] procedure.
You supply the input data in the I/O buffer (typically in ASCII code). The list of data
descriptors describes the placeholders that will contain the internal form of the data
when it has been converted by the FORMATDATA[X] procedure.
The FORMATDATA[X] procedure uses the format supplied by the
FORMATCONVERT[X] procedure to format the data supplied in the I/O buffer. The
formatted data gets stored in the variables as described by the list of data descriptors.
Note that the list of data elements is actually unchanged on output, but the variables
now contain formatted data.