Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 28
Finding the Next Matching File Name
bytes given by the value in word 8. If the search returns an error, the error number is
returned in word 2.
If your program is running multiple concurrent searches, then you will also need to set
the tag parameter in the FILENAME_FINDNEXT_ procedure call. You can then check
which search is finishing by comparing words 9 and 10 of the FILENAME_FINDNEXT_
completion message with the tag supplied in the procedure call.
The following example performs asynchronous searching:
LITERAL NOWAIT = %B0000000001000000;
!Open $RECEIVE:
FILE^NAME ':=' "$RECEIVE" -> @S^PTR;
ERROR := FILE_OPEN_(FILE^NAME:@FILE^NAME '-' @S^PTR,
RECV^NUM);
IF ERROR <> 0 THEN ...
!Set up the search:
SEARCH^PATTERN ':=' "$*" -> @S^PTR;
PATTERN^LENGTH := @S^PTR '-' @SEARCH^PATTERN;
OPTIONS := NOWAIT;
ERROR := FILENAME_FINDSTART_(SEARCH^ID,
SEARCH^PATTERN:PATTERN^LENGTH,
!resolve^level!,
!device^type!,
!device^subtype!,
OPTIONS);
IF ERROR = 1 THEN ... !No match found
ELSE IF ERROR <> 0 THEN ... !Error condition
!Start searching:
ERROR := FILENAME_FINDNEXT_(SEARCH^ID);
IF ERROR <> 0 THEN ...
.
.
!Continue processing asynchronously
.
.
!Read $RECEIVE
READUPDATEX(RECV^NUM,SBUFFER,
READ^COUNT);
IF <> THEN
BEGIN
!Check if system message:
CALL FILE_GETINFO_(RECV^NUM,
ERROR);