:SET_SCRIPT_VAR
Use the :SET_SCRIPT_VAR script statement to set the values of script variables indirectly, using a placeholder instead of an explicit variable name. This lets you set multiple variables in a single script line and is particularly useful in processing loops.
Note: :SET_SCRIPT_VAR does not create script variables. Use :SET to create the variables and assign initial values first.
Syntax
: SET_SCRIPT_VAR Script variable = Value
Parameters
| Parameter | Description | Format |
|---|---|---|
| Script variable | Placeholder for the name of the script variable to assign a value to. Include enough leading characters to uniquely identify the variable — :SET_SCRIPT_VAR will complete the name automatically. Note: Do not start the placeholder with an ampersand (&). Follow the standard variable naming rules. For more information, see Variable Names. |
script literal or script variable |
| Value | Value to assign to the script variable. End the value with a hash (#). | script literal, script variable, or script function |
Important Considerations
Key considerations include:
- Accessing a script variable that does not exist causes an error.
- If the script variable cannot be uniquely identified, no value is assigned.
- The statement is not case-sensitive for variable names. Placeholders that differ only in case will access the same variable.
Examples
The following example uses a VARA object and a Job. Three variables are stored in the VARA object — End#, Start#, and Ultimo# — with their names in the Key column and their values in the Value 1 column.
The Job script defines a processing loop that reads variable names from the first column and values from the second, then assigns each value to the corresponding variable.
: SET &END# = ""
: SET &START# = ""
: SET &ULTIMO# = ""
: SET &HANDLE# = PREP_PROCESS_VAR (VARA.NEW.7 )
: PROCESS &HANDLE#
: SET &VARIABLE# = GET_PROCESS_LINE (&HANDLE# ,1)
: SET &VALUE# = GET_PROCESS_LINE (&HANDLE# ,2)
: SET_SCRIPT_VAR &VARIABLE# = &VALUE#
: PRINT "&VARIABLE# = &VALUE#"
: ENDPROCESS
: CLOSE_PROCESS &HANDLE#
The :PRINT statement writes one line per retrieved variable name and value in the activation report:
2017-02-28 13:46:59 - U0020408 End# = 20170227
2017-02-28 13:46:59 - U0020408 Start# = 20170224
2017-02-28 13:46:59 - U0020408 Ultimo# = 20170228
See also: