Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Assignment of values to variables

&pagelevel(4)&pagelevel

“Value assignment” is the assignment of contents (i.e. a value) to a simple or complex variable.

A distinction can be made between direct value assignment with the SET-VARIABLE command and value assignment using TERMINAL with the READ-VARIABLE command. This section describes direct value assignment using SET-VARIABLE only. Value assignment with READ-VARIABLE is described in section “Input to variables”.

The SET-VARIABLE command is used to assign values to variables. The assigned value can be the contents of other variables or the results of functions or complex expressions. SET-VARIABLE can be applied to both simple and complex variables. The relevant rules are described below.

The command name SET-VARIABLE need not be stated in assignments; it can be omitted. The string to the left of the equals sign is interpreted as a variable name.

If implicit declaration is allowed for a procedure, the variable does not have to be declared (implicit declaration is only allowed for simple variables, and if IMPLICIT-DECLARATION = *YES; see the SET-PROCEDURE-OPTIONS command on "SET-PROCEDURE-OPTIONS Set procedure attributes " or MODIFY-PROCEDURE-OPTIONS command on "MODIFY-PROCEDURE-OPTIONS Modify procedure attributes during procedure execution ").

If implicit declaration is not allowed, the variable must be declared before the first assignment. Assigning a value to a variable that is not declared results in an error.

In an assignment, the data type of the assigned value must always correspond to the data type of the variable to the left of the equals sign. The variable to the left of the equals sign can be assigned an arbitrary value only if it is declared with the data type ANY.

Variables that have been initialized using the DECLARE-CONSTANT command cannot be assigned a different value by means of SET-VARIABLE.