Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 13
Formatting Literals
You can include literals in your edit-descriptor string by enclosing each literal in single
quotation marks. The FORMATDATA[X] procedure copies these literals directly to the
output buffers without accessing a data descriptor.
The following example produces the same output as the previous example. However,
because the days of the week are constant values whatever the month, these values
can be expressed as literals. Note that now one less data descriptor is needed.
!Set up the edit descriptors and convert to internal form:
EFORMAT ':=' ["' SUN MON TUE WED THU FRI SAT'//,",
"7(I5)//7(I5)//7(I5)//7(I5)//7(I5)"];
SCALES := 0;
CONVERSION := 1;
ERROR := FORMATCONVERT(IFORMAT,IFORMATLEN,EFORMAT,
EFORMATLEN, SCALES,SCALE^COUNT,
CONVERSION);
IF ERROR <= 0 THEN ...
!Set up arrays for date of the month values:
INT^ARRAY1 ':=' [1,2,3,4,5,6,7];
INT^ARRAY2 ':=' [8,9,10,11,12,13,14];
INT^ARRAY3 ':=' [15,16,17,18,19,20,21];
INT^ARRAY4 ':=' [22,23,24,25,26,27,28];
INT^ARRAY5 ':=' [29,30];
!Set up list elements that point to the above arrays:
VLIST^LEN := 5;
FLAGS := 0;
VLIST[0].ELEMENT^PTR := @INT^ARRAY1;
VLIST[1].ELEMENT^PTR := @INT^ARRAY2;
VLIST[2].ELEMENT^PTR := @INT^ARRAY3;
VLIST[3].ELEMENT^PTR := @INT^ARRAY4;
I := 0;
WHILE I < VLIST^LEN DO
BEGIN
VLIST[I].ELEMENT^SCALE := 0;
VLIST[I].ELEMENT^TYPE := 2;
VLIST[I].ELEMENT^LENGTH := 2;
VLIST[I].ELEMENT^OCCURS := 7;
I := I + 1;
END;
VLIST[4].ELEMENT^PTR := @INT^ARRAY5;
VLIST[4].ELEMENT^OCCURS := 2;
!Format the data:
ERROR := FORMATDATA(BUFFERS,BUFFER^LENGTH,NUM^BUFFERS,
BUFFER^ELEMENTS,WFORMAT,
VLIST,VLIST^LEN,
FLAGS);
IF ERROR <> 0 THEN ...
Figure 19-6 shows the effect of the above code fragment.