Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 19
Modifying One Part of a File Name
Modifying One Part of a File Name
Use the level parameter to specify the part of the file name you want to change. The
following example replaces the volume name of the file name
\SYSA.$YOURVOL.RECORDS.LOGFILE:
LITERAL MAXLEN = 256;
LITERAL VOLUME^LEVEL = 0;
.
.
FNAME ':=' "\SYSA.$YOURVOL.RECORDS.LOGFILE" -> @S^PTR;
FNAME^LENGTH := @S^PTR '-' @FNAME;
NEW^PART ':=' "$OURVOL" -> @S^PTR;
PART^LENGTH := @S^PTR '-' @NEW^PART;
ERROR := FILENAME_EDIT_(FNAME:MAXLEN,
FNAME^LENGTH,
NEW^PART:PART^LENGTH,
VOLUME^LEVEL);
IF ERROR <> 0 THEN ... !Error condition
In the example above, the name to be changed and its length are passed to the
FILENAME_EDIT_ procedure in FNAME and FNAME^LENGTH. The new value of the
volume part of the name and its length are passed in NEW^PART:PART^LENGTH.
The procedure uses this information to replace the volume part in the old file name
because the volume level (level 0) is specified in the level parameter.
The edited file name is returned in FNAME and its length in FNAME^LENGTH.
Replacing a File-Name Suffix or File-Name Prefix
To replace a file-name suffix of more than one part, you need to set the suffix flag
(bit 15) in the options parameter to 1. The level parameter identifies the start of
the suffix. The supplied replacement string is substituted for the part specified by the
level parameter and all parts to its right. Similarly, you can replace a file-name prefix
by setting the prefix flag (bit 14) in the options parameter to 1. The level
parameter identifies the last part of the prefix.
The following example changes the input file name from
\SYSA.$OURVOL.RECORDS.LOGFILE to \SYSA.$OURVOL.RECORDS1.ARCHIVE.
That is, the subvolume and file ID are replaced:
LITERAL MAXLEN = 256;
LITERAL SUBVOL^LEVEL = 1;
LITERAL SUFFIX = %B0000000000000001;
.
.
FNAME ':=' "\SYSA.$OURVOL.RECORDS.LOGFILE" -> @S^PTR;
FNAME^LENGTH := @S^PTR '-' @FNAME;
NEW^PIECE ':=' "RECORDS1.ARCHIVE" -> @S^PTR;
PIECE^LENGTH := @S^PTR '-' @NEW^PIECE;
ERROR := FILENAME_EDIT_(FNAME:MAXLEN,
FNAME^LENGTH,
NEW^PIECE:PIECE^LENGTH,