1.0;SETVAR, revision 1.0, 86/01/10
SETVAR (SET_VARIABLE) -- Set the value of a variable
usage: SETVAR {[-TYPE {STR|INT|BOOL|ANY|ENV}] var_name value ... |
variable/value_list}
FORMAT
SETVAR [options] {[-TYPE type] var_name value ... | variable_list}
The SETVAR command takes pairs of arguments, which may be preceded by an
optional type-specifier (-TYPE type).
By default, the type of each variable specified in the SETVAR command depends
on the type of each input value. You can, however, use the -TYPE argument to
specify the individual type(s) of the the variables.
Note: if a value is not of the type specified by the -TYPE argument an error
will result.
ARGUMENTS
variable_list
(optional)
Specify the names of the variables that receive the input
values.
Default if omitted: must specify -TYPE (below).
OPTIONS
-TYPE type var_name...
Specify the type of the input value(s) that can be assigned
to the particular variable name(s). Multiple variable
names are permitted, separated by blanks. Once you specify
a type in a particular SETVAR command, SETVAR assigns that
type to all subsequent variable names, until you change the
type specification. Valid types are:
STR[ING] character strings
INT[EGER] integer numbers
BOOL[EAN] Boolean values
ENV[IRONMENT] environment variables
ANY any type (the default)
If the type of the input value does not match the type
specified for that variable name, SETVAR issues an error
and asks you enter another input value. Use -TYPE ANY to
restore the Shell to its default state. In this case, it
determines the proper variable type automatically.
Specifying -TYPE ENV var_name causes the variable to become
an environment variable. Environment variables are of
primary concern to DOMAIN/IX users; please consult the
DOMAIN/IX documentation for details about their usage.
EXAMPLES
In the first example, we will create several variables using SETVAR and then
list them using the LVAR command.
$ setvar i 1 # an integer
$ setvar b true # a boolean
$ setvar s1 string # a string
$ setvar -type string s2 true # a boolean forced into a string
$ lvar i b s1 s2
integer i = 1
boolean b = true
string s1 = string
string s2 = true
In this example, we will set several variables of different types and then
list them.
$ setvar -type int i1 1 i2 2 -type str s1 3 s2 4 -type any i3 1
$ lvar i1 i2 s1 s2 i3
integer i1 = 1
integer i2 = 2
string s1 = 3
string s2 = 4
integer i3 = 1
The following is an error message example. In this case, we are trying to set
an integer to a string.
$ setvar -type int z ten
?(sh) semantic error - 'ten' is not an integer.
RELATED TOPICS
More information is available. Type:
- HELP EOFF
for details about restricting variable evaluation to within
variable expressions.
- HELP EON
for details about enabling global variable evaluation.
- HELP EXISTVAR
for details about existing variables.
- HELP EXPORT
for information about environment variable.
- HELP DLVAR
for information about deleting a variable.
- HELP READ
for information on assigning multi-character strings to variables.
- HELP READC
for information on assigning whole-line strings to variables.
- HELP READLN
for information on assigning whole-line strings to variables.