Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 19
Sample Program: Formatting Output
The following sample program is a complete program for printing the calendar page as
illustrated in Figure 19-7. This example shows all data declarations and includes error
checking for the FORMATCONVERT and FORMATDATA procedures.
The last lines of the example print out the contents of the buffers on the home terminal.
?INSPECT,SYMBOLS, NOLIST
?SOURCE $TOOLS.ZTOOLD04.ZSYSTAL
?LIST
!Global literals and variables:
LITERAL MAXFLEN = ZSYS^VAL^LEN^FILENAME;
INT ERROR;
INT TERM^NUM;
?NOLIST
?SOURCE $SYSTEM.SYSTEM.EXTDECS0(FORMATCONVERT,FORMATDATA,
? PROCESS_GETINFO_,FILE_OPEN_,WRITEX,
? INITIALIZER,DNUMOUT,DEBUG,PROCESS_STOP_)
?LIST
!------------------------------------------------------------
! Here are some DEFINEs to make it a little easier to
! format and print messages.
!------------------------------------------------------------
! Initialize for a new line:
DEFINE START^LINE = @S^PTR := @ERROR^BUFFER #;
! Put a string into the line:
DEFINE PUT^STR(S) = S^PTR ':=' S -> @S^PTR #;
! Put and integer into the line:
DEFINE PUT^INT(N) =
@S^PTR := @S^PTR '+' DNUMOUT(S^PTR,$DBL(N),10) #;
! Print the line:
DEFINE PRINT^LINE =
CALL WRITE^LINE(ERROR^BUFFER,
@S^PTR '-' @ERROR^BUFFER) #;