:SET

Use the :SET statement to assign a value to a variable. You can use :SET on its own, or can combine it with the :DEFINE statement to declare the data type of the variable. If you use :SET alone, the variable can only store strings or positive integers, and is not tied to a particular data type. You can also use :SET to solve an arithmetic expression.

More Information:

Syntax

:S[ET] Script variable = Value

Parameters

  • :SET
    Assigns a value to a script variable

  • 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: 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.

Important! You can use :SET and :RSET to assign different values to the same script variable. The values are set by those statements when you execute the Job. If you restart the Job, the value that the :RSET statement previously stored in the report is used.

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#

See also: