:SET

Use the :SET statement to assign a value or the result of an arithmetic expression to a script variable. Script variables are dynamically typed by default; this means that their data type is inferred from their content and how they are used. For instance, while most non-numeric data is represented as plain text, positive numbers, including 0, have a specific representation, such as being automatically padded to 16 digits. If you need to explicitly define a variable's data type before assignment, use the :DEFINE statement before :SET. To create or update an object variable based on a script variable use the :PSET or :RSET statement.

More Information:

Syntax

:S[ET] Script variable = Value

Parameters

  • Script Variable
    Name of the script variable
    Format: script variable
    Follow the rules for variable names. For more information, see Variable Names.

  • Value
    Value that is assigned to the script variable
    Format: Arithmetic expression, script literal, script variable, or script function

Notes:

  • You can use predefined variables such as &$CLIENT# to supply numerical values. Write the predefined variable as a value and enclose the variable in parentheses. Predefined variables are automatically converted to the default 16-digit format.
  • If the variable you specify with the :SET statement does not exist yet, the system creates the variable. Variables that are created in this manner do not have a specific data type.

Examples

The following example assigns a string to a script variable called &FILENAME#:

:SET &FILENAME# = "L.LST.FILE"

The following example uses the SYS_DATE script function to retrieve the current date, and assigns that date to a script variable called &TODAY#:

:SET &TODAY# = SYS_DATE(YYMMDD)

The following example assigns a numerical value to a script variable:

:SET &NUMBER# = 1

The following example assigns the value of one script variable to another variable:

:SET &NR# = &NUMBER#

The following example concatenates multiple values and assigns the value to another variable:

:SET &LONG_STRING# = "&PREFIX#-&VALUE#-&SUFFIX#"

The following example assigns the result of an arithmetic expression:

:SET &NR# = (1 + &NUMBER#) * &NUMBER#

See also: