Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 42
Editing a Character String
! 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);
! Upshift all characters in the edited command in case
! any characters were typed in lowercase:
CALL SHIFTSTRING(COMMAND,NUM,0);
END