Lesson 10: Dereferencing with SETVAR [ MPE V to MPE XL: Getting Started ] MPE/iX 5.0 Documentation
MPE V to MPE XL: Getting Started
Lesson 10: Dereferencing with SETVAR
Suppose you want to change your MPE XL prompt to reflect the name of the
group you are currently logged on to. You would assign to the HPPROMPT
variable the value of the system variable HPGROUP, by dereferencing
HPGROUP in a SETVAR statement. Try entering the following:
SETVAR HPPROMPT, "!HPGROUP/"
What happened? Your screen should look something like this (your group
name will probably be different):
__________________________________________________________________
| |
| |
| :SETVAR HPPROMPT,"!HPGROUP/" |
| HOME/ |
| |
__________________________________________________________________
Notice that the example includes a nonalphabetic character (/) after
!HPGROUP, just to separate visually the group name from the user input.
Now enter the command SHOWTIME.
___________________________________________________________________
| |
| |
| HOME/SHOWTIME |
| FRI, JUL 14, 1989 12:47 PM |
| HOME/ |
| |
___________________________________________________________________
Notice that the prompt has not changed. Use SHOWVAR to look at the value
of HPPROMPT.
___________________________________________________________________
| |
| |
| HOME/SHOWVAR HPPROMPT |
| HPPROMPT = HOME/ |
| HOME/ |
| |
___________________________________________________________________
Now change to the LABS group. Has your prompt changed? Use SHOWME to
verify that you are in the LABS group.
___________________________________________________________________
| |
| |
| HOME/CHGROUP LABS |
| HOME/SHOWME |
| USER: #S13,XYZ.FINANCE,LABS (NOT IN BREAK) |
| . |
| . |
| . |
| HOME/ |
| |
___________________________________________________________________
Why didn't the prompt change when the group changed? Because upon
dereferencing HPGROUP in the SETVAR statement, the system took the actual
value of HPGROUP and assigned it to HPPROMPT. And at that moment, the
value of HPGROUP was HOME.
However, there is a way to tell the system to change the value of
HPPROMPT so that it always shows the name of the current group. This is
accomplished in the example below (keep in mind that, in the example, the
user is still in the LABS group).
___________________________________________________________________
| |
| |
| HOME/SETVAR HPPROMPT,"!!HPGROUP/" |
| LABS/SHOWVAR HPPROMPT |
| HPPROMPT = !HPGROUP/ |
| LABS/CHGROUP |
| HOME/CHGROUP PUB |
| PUB/CHGROUP |
| HOME/ |
| |
___________________________________________________________________
Try it yourself. Notice the use of two exclamation points (!!) in the
SETVAR statement. This is what causes the system to assign not the
present value of HPGROUP to the prompt variable, but rather the
dereferenced variable itself (plus the slash, of course). Therefore,
each time the user changes groups, the prompt (which equals !HPGROUP plus
a /) also changes.
NOTE The process of using two exclamation points to dereference a
variable is called recursive dereferencing. You can read more
about recursive dereferencing in Command Interpreter Access and
Programmer's Guide (32650-90011).
Exercises
17. How would you change the following command line in order to include
the account name after the group name?
SETVAR HPPROMPT,"!!HPGROUP/!!HPCMDNUM:"
18. How would the prompt look (in exercise 17) in the PUB group of the
SALES account, if the current command line number is 16?
MPE/iX 5.0 Documentation