Subject: | |
From: | |
Reply To: | |
Date: | Thu, 30 Dec 1999 10:19:01 -0800 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
From call-id A5052608
MPE: How to create CI variables with local (command file) scope
Problem Description
I have separate command files that use the same variable names in
them. If one of the command files calls the other, then they both
affect the same global variable with undesirable results. Is
there the concept of a CI variable with its scope local to the
command file?
Solution
No. All user-defined CI variables have global (JOB/SESSION) scope.
Some HP Defined CI variables (HPFILE, HPPIN, HPUSERCMDEPTH) return
a different value depending on the context within the JOB/SESSION
when they are called.
HPFILE returns the fully qualified filename of the command file.
HPPIN returns the PIN of the calling process.
HPUSERCMDEPTH returns the command file call nesting level.
To get the effect of local scope using global variables, you need a
naming convention to prevent name collisions. There are several cases
to consider.
1. Command file CMDA calls CMDB both using varname VAR1.
A. Use a hardcoded prefix in each command file.
In CMDA use: SETVAR CMDA_VAR1 1
In CMDB use: SETVAR CMDB_VAR1 2
B. Use HPFILE.
SETVAR ![FINFO(HPFILE,"FNAME")]_VAR1 1
C. Use HPUSERCMDEPTH.
SETVAR D!"HPUSERCMDEPTH"_VAR1 1 Note: need a leading non-digit
2. Command file CMDA calls itself, uses varname VAR1.
A. Same answer as case 1 solution C. Use HPUSERCMDEPTH.
3. There are 2 son process. Each one calls CMDA which calls CMDB at the
same nesting level.
A. Same answer as case 1 solution C. Use HPUSERCMDEPTH. Not sure if
this will work since not sure if HPUSERCMDEPTH is reset at JSMAIN,
CI, or user process level.
B. Use HPPIN and HPUSERCMDEPTH.
SETVAR P!"HPPIN"_!"HPUSERCMDEPTH"_VAR1 1
C. Use HPPIN, HPUSERCMDEPTH and HPFILE (guaranteed unique, hard to
read)
SETVAR
P!"HPPIN"_!"HPUSERCMDEPTH"_![FINFO(HPFILE,"FNAME")]_![FINFO(HPFILE,
"GROUP ")]_![FINFO(HPFILE,"ACCT")]_VAR1 1
Again, there is no true local scope, only global scope for CI variables.
|
|
|