Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 40
Manipulating File Names: An Example
!------------------------------------------------------------
! Main procedure determines kind of file name or pattern,
! resolves the name, and calls either PRINT^NAME for file
! names or DEFINEs or FIND^FILES for a file-name pattern.
!------------------------------------------------------------
PROC INITIAL MAIN;
BEGIN
INT COUNT,KIND,LEVEL,OPTIONS; !parameters for
! FILENAME_SCAN_
INT FULL^LENGTH; !length of resolved
! file name or pattern
STRING .FULLNAME [0:MAXLEN - 1]; !resolved file name
STRING .PATTERN [0:MAXPATTERN - 1];!resolved name pattern
! Read and save the Startup message and open the IN and OUT
! files:
CALL INIT;
! Scan the file name or pattern returned from Startup
! message:
OPTIONS := ACCEPT^PATTERNS;
ERROR := FILENAME_SCAN_(CI^STARTUP.PARAM:PARAM^LEN,
COUNT,
KIND,
LEVEL,
OPTIONS);
IF ERROR <> 0 THEN CALL FILE^ERRORS(ERROR);
! Switch depending on whether parameter string is a file
! name, a name pattern, or a DEFINE:
CASE KIND OF
BEGIN
! If it is a file name:
0 -> BEGIN
! Resolve file name to fully qualified form:
ERROR := FILENAME_RESOLVE_(
CI^STARTUP.PARAM[0]:COUNT,
FULLNAME:MAXLEN,
FULL^LENGTH);
IF ERROR <> 0 THEN CALL FILE^ERRORS(ERROR)
! Call PRINT^NAME to print the file name:
ELSE CALL PRINT^NAME(FULLNAME,FULL^LENGTH);
END;