Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 17
Extracting Pieces of File Names
If, for example, the input string is “$OURVOL.MYSUB.PROGA” and you want the file-
name prefix returned up to and including the subvolume, then “$OURVOL.MYSUB” is
returned. The node name, although specified in the default values, is not returned.
The code to execute this example is shown below:
LITERAL MAXLEN = 256;
LITERAL SUBVOL^LEVEL = 2;
LITERAL EXTRACT^PREFIX = %B0000000000000010;
LITERAL NO^DEFAULTS = %B0000000000000100;
.
.
OPTIONS := EXTRACT^PREFIX LOR NO^DEFAULTS;
ERROR := FILENAME_DECOMPOSE_(FNAME:LENGTH,
PREFIX^PIECE:MAXLEN,
PREFIX^LENGTH,
SUBVOL^LEVEL,OPTIONS);
IF ERROR <> 0 THEN ... !Error condition
Extracting Subparts of a Process Descriptor
If the name you are decomposing is a process descriptor, then you can divide the
name further to extract subparts of the process name or identifying part of an unnamed
process. To do this, you must include the subpart parameter in the procedure call.
This parameter occurs at the end of the parameter list and can have any of the
following values:
Values 1 and 2 apply only to unnamed processes. Value 4 applies only to named
pr
ocesses. Values 0 and 3 apply to named and unnamed processes.
The following example returns only the process sequence number in the variable
SEQ
^NUM:
LITERAL MAXLEN = 16;
LITERAL PROCESS^NAME = 0;
LITERAL EXTRACT^SEQ^NUM = 3;
.
.
LEVEL := PROCESS^NAME;
SUBPART := EXTRACT^SEQ^NUM;
ERROR := FILENAME_DECOMPOSE_(FNAME:LENGTH,
SEQ^NUM:MAXLEN,SEQ^NUM^LENGTH,
LEVEL,
!options!,
0 Return the entire element (the default action).
1 Return only the CPU part of an unnamed process-file name.
2 Return only the PIN.
3 Return only the process sequence number.
4 Return only the name subpart.