Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 36
Manipulating File Names: An Example
INT PARAM^LEN; !length of PARAM string
?NOLIST, SOURCE $SYSTEM.SYSTEM.EXTDECS0(INITIALIZER,
? FILE_OPEN_,FILENAME_SCAN_,FILENAME_RESOLVE_,
? FILENAME_FINDSTART_,FILENAME_FINDNEXT_,
? FILENAME_FINDFINISH_,WRITEX,PROCESS_STOP_,DNUMOUT,
? OLDFILENAME_TO_FILENAME_,FILE_GETINFO_)
? LIST
!------------------------------------------------------------
! These DEFINEs help to format and print messages.
!------------------------------------------------------------
! Initialize for a new line:
DEFINE START^LINE = @S^PTR := @SBUFFER #;
! Put a string into the line:
DEFINE PUT^STR(S) = S^PTR ':=' S -> @S^PTR #;
! Put an integer into the line:
DEFINE PUT^INT(N) =
@S^PTR := @S^PTR '+' DNUMOUT(S^PTR,$DBL(N),10) #;
!------------------------------------------------------------
! Procedure to print file-system error numbers on the
! output file.
!------------------------------------------------------------
PROC FILE^ERRORS(ERROR);
INT ERROR;
BEGIN
STRING .SBUFFER[0:36]; !output buffer
START^LINE;
PUT^STR ("File System Error Number Is: ");
! Write error to output file:
PUT^INT (ERROR);
CALL WRITEX(INNUM,SBUFFER,@S^PTR '-' @SBUFFER);
! Stop the process:
CALL PROCESS_STOP_;
END;