Guardian Programmer's Guide

Table Of Contents
Formatting and Manipulating Character Data
Guardian Programmer’s Guide 421922-014
19 - 37
Editing a Character String
Upshifting a Character String
To upshift a character string, you supply the SHIFTSTRING procedure with the string
to be upshifted and the length of the string. To specify upshifting, you must set bit 15
of the casebit parameter to 0 (the default value). The following example converts an
input string to all uppercase letters:
STRING ':=' INPUT^BUFFER FOR 10;
STRING^LENGTH := 10;
CASE^BIT.<15> := 0;
CALL SHIFTSTRING(STRING,
STRING^LENGTH,
CASE^BIT);
Any nonalphabetic characters in the input string remain unchanged. Uppercase
alphabetic characters in the input string also remain unchanged.
Downshifting a Character String
To downshift any uppercase alphabetic characters in a string, you should use the
SHIFTSTRING procedure with bit 15 of the casebit parameter set to 1. For
example:
CASE^BIT.<15> := 1;
CALL SHIFTSTRING(STRING,
STRING^LENGTH,
CASE^BIT);
Editing a Character String
The FIXSTRING procedure edits a string based on commands provided in a template.
The FIXSTRING procedure is commonly used in an interactive process to implement a
command that edits command strings. For example, the FC command uses the
FIXSTRING procedure to edit any other command; see the Guardian User’s Guide for
details. Likewise, the FC command in Debug uses the FIXSTRING procedure; see the
Inspect Manual for details.
The FIXSTRING procedure works by supplying the ASCII string you want to edit and a
template containing the edit commands. The ASCII string can be any sequence of
ASCII characters whose length can be limited by supplying the max-data-len
parameter. The template contains commands for replacing, deleting, and inserting
characters.
The following TAL statement shows an example of the FIXSTRING procedure:
CALL FIXSTRING(TEMPLATE, !string array of edit commands
TEMPLATE^LEN, !length of template
DATA, !string to edit
DATA^LENGTH, !length of string
MAX^DATA^LEN); !maximum length of edited
! string