Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 59
Sample Program
! Set the FC prompt to " ." and read template typed by
! user:
TEMPLATE^ARRAY ':=' " .";
CALL WRITEREADX(TERM^NUM,TEMPLATE^ARRAY,2,72,
TEMPLATE^LENGTH);
! If WRITEREADX returns an error, or if the template
! contains exactly two slashes, then return with no
! changes:
IF > OR TEMPLATE^LENGTH = 2
AND TEMPLATE^ARRAY = "//" THEN
BEGIN
NUM := SAVE^NUM;
COMMAND ':=' LAST^COMMAND FOR NUM;
RETURN 0;
END;
! Otherwise call FIXTRING to alter the command according
! to the instructions in the template:
CALL FIXSTRING(TEMPLATE^ARRAY,TEMPLATE^LENGTH,COMMAND,
NUM,MAX^LEN);
IF > THEN
BEGIN
! The replacement string is greater than MAX^LEN, so
! print a diagnostic message and return to beginning
! of loop:
BUFFER ':=' "Replacement string too long "
-> @S^PTR;
CALL WRITEX(TERM^NUM,BUFFER,@S^PTR '-' @BUFFER);
IF <> THEN CALL PROCESS_STOP_(!process^handle!,
!specifier!,
ABEND);
END
ELSE IF < THEN CALL PROCESS_STOP_(!process^handle!,
!specifier!,
ABEND);
! Trim multibyte fragments from end of string:
CALL MBCS_TRIMFRAGMENT_(@COMMAND,NUM);
! Replace multibyte blanks with two ASCII blank
! characters:
CALL MBCS_REPLACEBLANK_(@COMMAND,NUM);