:SET_SCRIPT_VAR

ScriptEigener Objekttyp in der Automation Engine 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.

The 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 an "&" 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.

In earlier versions, :SET_SCRIPT_VAR accepted a leading "&" in the variable name stored in the value of the variable passed to the script statement. Starting with v11.2, this is no longer allowed.

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.

The script values must end with a "#" character.

In earlier versions, a "#" character was is automatically added to the end of the variable name, when it was not already there. Starting with version 11.2, no "#" character is automatically added to the end of the variable name. Therefore, if you want the variable name to end with a "#" character, which is the best practice or requirement distinct variables, you must explicitly include it in the value of the variable passed to :SET_SCRIPT_VAR.

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.

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 1

This example sets the script value &var_name# to the value of &var_value#.

:SET &VAR_1# = ""

:SET &var_name# = "VAR_1#"

:SET &var_value# = "ABC"

:SET_SCRIPT_VAR &var_name# = &var_value#

:SET &temp# = GET_SCRIPT_VAR(&var_name#)

:PRINT "Variable name stored in &var_name# : &var_name#"

:PRINT "Value from :SET_SCRIPT_VAR/GET_SCRIPT_VAR : &temp#"

:PRINT "Value retrieved directly from variable : &VAR_1#"

ReportBericht, der nähere Informationen über die Durchführung einer Aufgabe oder einer Komponente enthält. extract:

2017-01-10 10:10:38 - U00020408 Variable name stored in VAR_1# : VAR_1#

2017-01-10 10:10:38 - U00020408 Value from :SET_SCRIPT_VAR/GET_SCRIPT_VAR : ABC

2017-01-10 10:10:38 - U00020408 Value retrieved directly from variable : ABC

Example 2

This example uses a VariableSpeichert oder ermittelt Werte dynamisch zur Laufzeit. Auch ein eigener Objekttyp in der Automation Engine. object and a job. In the Variable object, the key includes the names of the script variables End, Start, and Ultimo and their respective values.

In a processing loop, the job script reads the script variable names from the Variable object's Key column. Then it reads the script variable values from the second column. Afterward, the script assigns the retrieved values to the variables "&END#", "&START#" and "&ULTIMO#".

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

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

Report extract:

2017-02-31 13:46:59 - U0020408 End = 20170227
2017-02-31 13:46:59 - U0020408 Start = 20170224
2017-02-31 13:46:59 - U0020408 Ultimo = 20170231

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