Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 34
List-Directed Formatting
!------------------------------------------------------------
! Main procedure provides initialization
!------------------------------------------------------------
PROC INIT MAIN;
BEGIN
STRING .TERM^NAME[0:MAXFLEN - 1];
INT TERMLEN;
! Read the Startup message:
CALL INITIALIZER;
! Open the home terminal:
ERROR := PROCESS_GETINFO_(!process^handle!,
!file^name:maxlen!,
!file^name^len!,
!priority!,
!moms^processhandle!,
TERM^NAME:MAXFLEN,
TERMLEN);
IF ERROR <> 0 THEN CALL PROCESS_STOP_;
ERROR := FILE_OPEN_(TERM^NAME:TERMLEN,TERM^NUM);
IF ERROR <> 0 THEN CALL PROCESS_STOP_;
! Call the FORMAT^INPUT procedure:
CALL FORMAT^INPUT;
END;
Formatting List-Directed Output
List-directed output works like list-directed input in reverse. Here, the
FORMATDATA[X] procedure takes data from variables addressed by a list of data
descriptors and writes them to an output buffer in a format that depends on the data
type specified in the data descriptor.
For example, if the data type is character, then the stored information is interpreted as
ASCII code. If the data type is 16-bit integer, then each stored word is treated as an
integer value, converted to ASCII code, and written to the output buffer.
You specify list-directed output by setting bits in the flags parameter supplied to the
FORMATDATA[X] procedure. Set bit 15 to 0 to specify output. Set bit 2 to 1 to specify
list-directed formatting.