Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 12
Resolving Names
DEFINE mode is turned off.
The following example searches the subvolume list in a search DEFINE named
=FINDIT. It looks for a file whose file ID is PROGA:
NAME ':=' "PROGA" -> @S^PTR;
NAME^LENGTH := @S^PTR '-' @NAME;
SEARCH^DEFINE ':=' "=FINDIT" -> @S^PTR;
S^DEFINE^LENGTH := @S^PTR '-' @SEARCH^DEFINE;
ERROR := FILENAME_RESOLVE_(NAME:NAME^LENGTH,
FULLNAME:MAXLEN,
FULL^LENGTH,
!options!,
!override^name:length!,
SEARCH^DEFINE:S^DEFINE^LENGTH);
IF ERROR <> 0 THEN
CASE ERROR OF
BEGIN
11 -> !File not found
.
.
OTHERWISE -> !Other error
END;
You can force file-name resolution even though the search failed to find a match by
setting the search-fail-OK flag (bit 9) in the options parameter to 1 before calling
the FILENAME_RESOLVE_ procedure. The file ID will be qualified by the first
subvolume in the search DEFINE if no match is found.
Overriding the Input File Name With a DEFINE
Your program can give the user the ability to override the file name specified in the
input string by supplying the name of a DEFINE that contains an override file name. To
use this feature, your program must set the override parameter of the
FILENAME_RESOLVE_ procedure to the name of the DEFINE that provides the
override file name.
In the following example, the override name identifies a DEFINE named =MYDEFINE.
If the DEFINE exists, then the file named in the DEFINE overrides the file name
supplied in the input string in NAME. If the DEFINE does not exist, the input string in
NAME is used as in the normal case.
NAME ':=' "PROGA" -> @S^PTR;
NAME^LENGTH := @S^PTR '-' @NAME;
OVERRIDE^NAME ':=' "=MYDEFINE" -> @S^PTR;
ORIDE^NAME^LENGTH := @S^PTR '-' @OVERRIDE^NAME;
ERROR := FILENAME_RESOLVE_(NAME:NAME^LENGTH,
FULLNAME:MAXLEN,
FULL^LENGTH,
!options!,
OVERRIDE^NAME:ORIDE^NAME^LENGTH);
IF ERROR <> 0 THEN ... !Error condition