System-wide variables

»  Home

» Software
» Papers & Training
» Java

Preface

A few years ago I was thinking it would be nice to be able to set a variable that I could then read from other Jobs or Sessions. Over the years this kept coming up, and not to long ago it ended up on the requested enhancement list. CSY said they had preliminary plans to implement these but had no immediate plans to implement them. The more I thought about it the more I wanted them. So one day I decided to see if I could figure out how to do it, and what you see in the System Variable UDC’s is the result.

What are they?

The system variables are designed to store variables at three different levels. The first is at the system level. These can be set , read, and deleted by anyone on the system. Account level that can be set, read, and deleted by anyone in that account. And User level that can be set, read, and deleted by only that user. The variables are kept as files in the Posix file space so names can be up to 200 characters at present.

Installation

To install the System Variable UDC’s you simple need to do a SETCATALOG of the file at the system level. You can do this by typing "SETCATALOG SYSVAR.PUB.SYS;SYSTEM;APPEND".

Setup

By default you must initialize a System Variable area before you can store or retrive any variables. To set up the area for the variables at the system level you must type "INITVARAREA" (you must have SM to do this). This will allow you to set and retrive System level variables. To allow someone to use variables at the account level you must initialize the variable area for each account. You can do this by typing "INITVARAREA <acctname>" (You must be have either SM or AM to do this). To allow variables at the user level you need to set up the variable area for each user you want to be able to set and retrive variables at the user level. You can do this by typing "INITVARAREA <username.account>" (You must have SM or AM to do this)

How do you use them?

The System Variables are constructed to work almost the same as the current Variables. If you want to set a standard variable you would do something like
:SETVAR SECURITY_LEVEL,32
If you wanted to set this at a system level you would use SETSVAR instead
:SETSVAR SECURITY_LEVEL,32
The System Variables are also capable of evaluating functions as well
:SETSVAR FINAL_VALUE,WORD("THIS IS IT",,-1)
If you want to set these at the Account level instead then you would set them with a ";ACCOUNT" following the expresion.
:SETSVAR FINAL_VALUE,WORD("THIS IS IT",,-1);ACCOUNT
Or at the user level it would be
:SETSVAR FINAL_VALUE,WORD("THIS IS IT",,-1);USER
The system Variables also support the same three types as the standard variables (String, Numeric, and Boolean).

Now to be able to use one of these variables is a little different. Since they are stored in files you can’t reference them directly, you must retrieve them into a standard variable first. You can do this with the "GETSVAR" command.
:GETSVAR FINAL_VALUE
or
:GETSVAR FINAL_VALUE;ACCOUNT
Then you can use the variable FINAL_VALUE.

To delete a variable is the almost the same as well, with the DELSVAR command. You can add the ":ACCOUNT" or "USER" to delete those levels.

The last command is the SHOWSVAR. This will show the values for all the variables. It also works much like the SHOWVAR command in that it will take one particular name or a wild card for the variable name.
:SHOWSVAR DATE@;USER
These are the four standard commands. There are three others that accompany these, one is the INITVARAREA described above, the next is DELVARAREA that will delete the Variable environment and has the same syntax as the INITVARAREA command. And the last is the SETSVARSEC command. This works like the SETSVAR command except that you must be SM to set this at the system level and either SM or AM to set at the account level. These can not be change or deleted by the standard user, only read. They will also appear as half bright on a SHOWSVAR.

Setsvar

Assigns values to MPE/iX system variables.

SYNTAX
     SETSVAR varname{<space>} expression;{SYSTEM }
                    {,      }            {ACCOUNT}
                    {;      }            {USER   }
      

Getsvar

Gets a veriable from the SYSTEM, ACCOUNT, or USER area and sets a local variable of the same name to its value

SYNTAX
     GETSVAR varname;{SYSTEM }
                     {ACCOUNT}
                     {USER   }
      

Showsvar

Displays specific system variable names and their current values.

SYNTAX
     SHOWSVAR [varid];{SYSTEM }
                      {ACCOUNT}
                      {USER   }
      

Delsvar

Deletes one MPE/iX system variables.

SYNTAX
     DELSVAR varname;{SYSTEM }
                     {ACCOUNT}
                     {USER   }
      

Top    JazzInfo    Hosted by 3kRanger.com    email 3kRanger    Updated