: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 — their data type is inferred from their content and how they are used. For example, most non-numeric data is represented as plain text, while positive numbers including 0 are 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 :PSET or :RSET.

More information:

Syntax

: S[ET] Script variable = Value

Parameters

Parameter Description Format
Script variable Name of the script variable to assign a value to. Follow the rules for variable names. For more information, see Variable Names. Script variable
Value Value to assign to the script variable Arithmetic expression, script literal, script variable, or script function

Important Considerations

  • You can use predefined variables such as &$CLIENT# to supply numerical values. Write the predefined variable as the value and enclose it in parentheses. Predefined variables are automatically converted to the default 16-digit format.

  • If the variable specified in the :SET statement does not exist yet, the system creates it automatically. Variables created this way do not have a specific data type.

Examples

The following example assigns a string to a script variable.

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

The following example uses the SYS_DATE script function to retrieve the current date and assigns it to a variable.

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

: SET &NR# = &NUMBER#

The following example concatenates multiple values and assigns the result to a variable.

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

The following example assigns the result of an arithmetic expression.

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

See also: