Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 13
Truncating Default Parts of File Names
An alternative way to specify the override name is to use a map DEFINE with the same
name as the file ID in the input string, prefixed with an equal sign (=). You can do this
by setting the automatic-override flag (bit 8) in the options parameter to 1
before calling the FILENAME_RESOLVE_ procedure.
The following example resolves the file name in a DEFINE called =PROGA. If there is
no such DEFINE, the input string PROGA is used:
LITERAL AUTO^OVERRIDE = %B0000000010000000;
.
.
NAME ':=' "PROGA" -> @S^PTR;
NAME^LENGTH := @S^PTR '-' @NAME;
OPTIONS := AUTO^OVERRIDE;
ERROR := FILENAME_RESOLVE_(NAME:NAME^LENGTH,
FULLNAME:MAXLEN,
FULL^LENGTH,
OPTIONS);
IF ERROR <> 0 THEN ... !Error condition
Truncating Default Parts of File Names
To truncate the applicable default values for node name, volume name, and subvolume
name from a file name, use the FILENAME_UNRESOLVE_ procedure. You may want
to do this, for example, before displaying file names to local users.
The default values used by the FILENAME_UNRESOLVE_ procedure may be all or
some of the current default values specified in the =_DEFAULTS DEFINE or they may
be specified in an alternate defaults DEFINE. The following paragraphs describe these
options.
Truncating All Current Default Values
The file-name elements removed by the FILENAME_UNRESOLVE_ procedure are
normally those that compare with the values set up in the =_DEFAULTS DEFINE.
The following example removes from a file name all elements that match the current
default. The file name to be unresolved is passed to the procedure in FNAME and is
returned, stripped of the default values, in SHORT^NAME:
LITERAL MAXLEN = 256;
.
.
ERROR := FILENAME_UNRESOLVE_(FNAME:LENGTH,
SHORT^NAME:MAXLEN,
SHORT^NAME^LENGTH);
IF ERROR <> 0 THEN ... !Error condition
Caution. Passing an invalid file name or file-name pattern to the FILENAME_UNRESOLVE_
procedure can result in a signal, trap, or data corruption. To verify that a file name is valid, use
the FILENAME_SCAN_ procedure.