0.9b (c) 1995 Peter Childs
>>-VALUE(name---+--------------------------------+---)--->< +-,--+-----------+-+-----------+-+ +-newvalue--+ +-,selector-+
VALUE returns the value of the symbol named by name, and optionally assigns it a new value. By default, VALUE refers to the current REXX-variables environment, but other, external collections of variables may be selected. If you use the function to refer to REXX variables, then name must be a valid REXX symbol. (You can confirm this by using the SYMBOL function.) Lowercase characters in name are translated to uppercase. If name is a compound symbol, then REXX substitutes symbol values to produce the derived name of the symbol.
If you specify newvalue, then the named variable is assigned this new value. This does not affect the result returned; that is, the function returns the value of name as it was before the new assignment.
Here are some examples:
/* After: Drop A3; A33=7; K=3; fred='K'; list.5='Hi' */ VALUE('a'k) -> 'A3' VALUE('a'k||k) -> '7' VALUE('fred') -> 'K' /* looks up FRED */ VALUE(fred) -> '3' /* looks up K */ VALUE(fred,5) -> '3' /* and sets K=5 */ VALUE(fred) -> '5' VALUE('LIST.'k) -> 'Hi' /* looks up LIST.5 */
To use VALUE to manipulate OS/2 environment variables, selector must be the string 'OS2ENVIRONMENT' or an expression so evaluated. In this case, the variable name need not be a valid REXX symbol. When VALUE is used to set or change the value of an environment variable, the new value is retained after the REXX procedure ends.
Here are some examples:
/* Given that an external variable FRED has a value of 4 */ share = 'OS2ENVIRONMENT' say VALUE('fred',7,share) /* says '4' and assigns */ /* FRED a new value of 7 */ say VALUE('fred',,share) /* says '7' */ /* After this procedure ends, FRED again has a value of 4 */
/* Accessing and changing OS/2 environment entries */ env = 'OS2ENVIRONMENT' new = 'C:\LIST\PROD;' say value('prompt',,env) /* says '$i[p]' (perhaps) */ say value('path',new,env) /* says 'C:\EDIT\DOCS;' (perhaps) */ /* and sets PATH = 'C:LIST\PROD' */ say value('path',,env) /* says 'C:LIST\PROD' */ /* When this procedure ends, PATH = 'C:\LIST\PROD' */
Notes:
1. If the VALUE function refers to an uninitialized REXX variable, then the default value of the variable is always returned; the NOVALUE condition is not raised. NOVALUE is never raised by a reference to an external collection of variables.
2. The VALUE function is used when a variable contains the name of another variable, or when a name is constructed dynamically. If the name is specified as a single literal string, the symbol is a constant and so the whole function call can usually be replaced directly by the string between the quotation marks. (For example, fred=VALUE('k'); is identical to the assignment fred=k;,unless the NOVALUE condition is being trapped.
3. To effect temporary changes to environment variables, use the SETLOCAL and ENDLOCAL functions.
Inf-HTML End Run - Successful