SET

You can use this function to change the value of data in a variable.

The format of this function is SET %target = operand2 { +- Operand3}.

The SET function can be expressed using various methods. All expression methods require a variable to be in the target field of the function. When a variable is used as operand 2 or operand3 of a SET function, the variable must have been initialized. Otherwise, an error occurs. Character data specified in operand 2 or operand3 must be enclosed in double quotation marks.

The following examples show the various expression methods of the SET function:

  • SET %A = 1

    This command sets the variable %A to 1.

  • SET %A = "TEST.DATA"

    This command sets the variable %A to TEST.DATA.

  • SET %A = %A - 1

    This command subtracts 1 from the numeric variable %A, and then assigns the result to the numeric variable %A.

  • SET %B = %A + 1

    This command adds 1 to the numeric variable %A, and then assigns the result to the numeric variable %B.

  • SET %A = %A + %B

    This command adds the values of the variable %A and the variable %B, and then assigns the result to the variable %A.

    If two character fields are added together, the fields are concatenated. If numeric and character variables are mixed, the numeric field is converted to a character field and the resulting target field is a concatenation of the two fields.

  • SET %NUM = number

    The script program OSIUC000 supports length subscript to be used in numeric script variables when performing a conversion to character variables. Before this, when converting a numeric variable to a character variable, leading zeroes are not included.

    For example, SET %NUM = 1234. It supports the following expression methods:

    • SAY NUM = %NUM

      The output of the SAY command is NUM = 1234.

    • SAY NUM = %NUM(2)

      The output of the SAY command is NUM = 34.

    • SAY NUM = %NUM(6)

      The output of the SAY command is NUM = 001234.