Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 11
19 Formatting and Manipulating Character Data
Using Buffer Control
It is often convenient to use multiple buffers for output from the FORMATDATA[X]
procedure. In addition to making it easier to handle larger amounts of output data,
multiple buffers also help format data into lines for output, because you can then issue
one WRITE procedure call for each buffer.
To terminate a buffer and start a new one, you put a slash (/) character in the edit
descriptor string. When using multiple buffers, the buffer parameter to the
FORMATDATA[X] procedure must identify a series of contiguous buffers.
The following code fragment expands the previous example by inserting two new-
buffer characters between the edit descriptors that correspond to the day of the week
and the edit descriptors that correspond to the date. The code fragment is expanded
to use 11 buffers, where one buffer contains the data for one line of a printed calendar.
!Set up the edit descriptors and convert to internal form:
EFORMAT ':=' ["7(A5)//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 month, year, and date values:
DAYS ':=' " MON TUE WED THU FRI SAT SUN"
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 := 6;
FLAGS := 0;
VLIST[0].ELEMENT^PTR := @DAYS;
VLIST[0].ELEMENT^SCALE := 0;
VLIST[0].ELEMENT^TYPE := 0;
VLIST[0].ELEMENT^LENGTH := 38;
VLIST[0].ELEMENT^OCCURS := 1;
VLIST[1].ELEMENT^PTR := @INT^ARRAY1;
VLIST[2].ELEMENT^PTR := @INT^ARRAY2;
VLIST[3].ELEMENT^PTR := @INT^ARRAY3;
VLIST[4].ELEMENT^PTR := @INT^ARRAY4;
I := 1;
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;