Using Persistent Variables

Persistent variables are variables, that don't lose their values between two runs of a program (even if you reboot your PC between the run).

There is no native support for persistent variables in REXX. Therefore you must implement the save and load process of those variables in your program yourself.

You can use a data file or an INI file (but not OS2.INI!) for this purpose.

Another place to save persistent variables is in the Extended Attributes of your REXX program. The adavantage of this method is, that you can move or copy the REXX program and the persistent variables will always be there. I've found this very clever hint in a message from Erik Schneller (see EMail Addresses).
Note that you should use the defined format for Extended Attributes also for your new Extended Attributes - see Extended Attribute Data Types - and you shouldn't use one of the predefined Extended Attributes - see Extended Attributes used by the WPS.

One disadvantage of this method is, that you'll lose the persistent variables if you use a DOS/Windows program to process the file. Note further that the maximum size of all Extended Attributes is limited to 64 K and that your new Extented Attributes may prevent the REXX interpreter from saving the token image of your REXX program in the EAs (see Creating a token image)

(see Sample for persistent variables for a working example using Extended Attributes for persistent variables)


[Back: Global variables across more than one REXX program]
[Next: When to Quote Variables in Functions and/or Procedures]