Automation Engine Script Guide > Ordered by Function > Script Structure and Processing > :SET_SCRIPT_VAR

:SET_SCRIPT_VAR

Script statement: Sets the values of script variables through indirect access.

Syntax

:SET_SCRIPT_VAR Script variable = Value

Syntax

Description/Format

Script variable

A placeholder for the name of the script variable that should obtain a value.

A script variable's name is limited to 32 alphanumeric characters, including the special characters "$", "_", "@", "ยง" and "#". German Umlauts are not allowed. The first character must not be a number. Variables within the script must always specified with a leading "&" following the variable name!

Format: script literal or script variable

Value

The value that is assigned to the script variable.
Format: script, script variable or script function

Comments

This script statement sets the values of script variables. It is not necessary to explicitly specify the names of the script variables. Script variables can indirectly be accessed using placeholders. These placeholders then have variable characters.

You can easily set the values of many script variables (such as in a processing loop). The script statement :SET_SCRIPT_VAR replaces many conditional statements that were so far required by a single scripting line.

Script variable passes a string on to the script statement that is used for the name of a script variable. Ensure that this string does not begin with "&" because this character is used to identify script variables. The minimum number of initial letters that is used for the script variable name (without &) should clearly identify the script variables. The script statement :SET_SCRIPT_VAR creates a valid script variable name and assigns a Value to it.

An error occurs if a script variable which that should be accessed does not exist.

No value is assigned if the specified string applies to the names of several script variables. Automic recommends using a string that ensures that the script variable can be clearly identified.

This script statement cannot be used to create script variables. This must be done beforehand using the statement :SET where the variables obtain initial values.

Note that this script element does not distinguish uppercase and lowercase letters in the names of script variables. This means that the system will always access the same script variable when you use placeholders (script variable) that are basically the same but use uppercase and lowercase characters differently.

Example

The example is based on a Variable object and a job. The names of script variables (key) and their values (value 1) are stored in a Variable object.

The script values must end with a # character.

In the job script, the name of the script variable is taken from the first column of the Variable object (using a processing loop). Afterwards the value of the script variable is taken from the second column. Subsequently, the retrieved values are assigned to the variables "&END#", "&START#" and "&ULTIMO#" in the script.

:SET &END#   = ""
:
SET &START#  = ""
:
SET &ULTIMO# = ""

:
SET &HANDLE# = PREP_PROCESS_VAR("SCRIPT_VARA")

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

Use PRINT in order to have the Variable object's values output in the activation report (Key = Value 1).

Report extract:

2005-02-03 13:46:59 - U0020408 End = 20051027
2005-02-03 13:46:59 - U0020408 Start = 20051024
2005-02-03 13:46:59 - U0020408 Ultimo = 20051031

 

See also:

Script element Description

RESOLVE_VAR

Resolves any kind of variable (prompt values, system variables, script variables, variable objects) in text.

GET_SCRIPT_VAR

Returns the values of script variables by indirect access.

:PSET

Assigns a value to an object variable.

:RSET

Assigns a value to a script variable and saves it to the activation report.

:SET This assigns a value to a script variable. The statement can be written in short or long form.

Script Elements - Script Structure and Processing

About Scripts
Script Elements - Alphabetical List

Script Elements - Ordered by Function