Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 30
Finding the Next Matching File Name
For files that are not disk files, words 2, 3, and 4 are undefined.
The following example uses the entityinfo parameter to determine whether a
returned entity is a temporary file name or a subvolume name (they both have the
same format). Word 2 of the entityinfo parameter is -1 for a subvolume but will
have some other value for a disk file:
SEARCH^PATTERN ':=' "$OURVOL.*" -> @S^PTR;
PATTERN^LENGTH := @S^PTR '-' @SEARCH^PATTERN;
ERROR := FILENAME_FINDSTART_(SEARCH^ID,
SEARCH^PATTERN:PATTERN^LENGTH);
IF ERROR <> 0 THEN ... !Error condition
ERROR := FILENAME_FINDNEXT_(SEARCH^ID,
NAME:MAXLEN,
NAMELEN,
ENTITY^INFO);
IF ERROR = 1 THEN ... !No match found
ELSE IF ERROR <> 0 THEN ... !Error condition
IF ENTITY^INFO[2] = -1 THEN ... !subvolume
ELSE IF ENTITY^INFO[2] <> -1 THEN... !temporary file
Handling Search Errors
For a waited search, errors are returned in the error variable. For a nowait search,
errors may be returned either in the error variable when the search is initiated or in
word 2 of the Nowait FILENAME_FINDNEXT_ completion message when the search
finishes.
If generic offline errors are reported (see Establishing the Start of a File-Name Search
earlier in this section), you can still continue with the search. You can recognize these
errors by the fact that, even though an error is returned, a name is also returned. For
these errors, the name is that of the entity (node or device) associated with the error
and may be a name that is not in the form being searched for. You can use this name
for error reporting.
Word 2 For disks, contains the object type.
If > 0, then the returned name refers to an SQL object type.
If 0, then the returned name refers to a non-SQL file.
If -1, then the returned name refers to a subvolume or volume.
Word 3 For a disk file, contains the file type:
0 for an unstructured file
1 for a relative file
2 for an entry-sequenced file
3 for a key-sequenced file
-1 for a volume or subvolume
Word 4 For a disk file, contains the file code given to the file. For a subvolume or
volume, this word contains -1.