Automation Engine Script Guide > Ordered by Function > Strings > STR_SUBSTITUTE_VAR

STR_SUBSTITUTE_VAR, STR_SUB_VAR

Script functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,…: Replaces script variableA placeholder for a value within a script. names by their values.

Syntax

STR_SUB[STITUTE]_VAR(Variables)

Syntax

Description/Format

Variables

Script variableIt stores or retrieves values dynamically at runtime. An individual Automation Engine object type. or string that includes one or several variable names.
Format: script literal or script variable

Return code

String with the script variable's values.

Comments

The script variable STR_SUB_VAR can be used to replace one or several script variable names that are stored as a string in a different script variable by the actual variable value. The following examples illustrate this behavior.

The scriptA particular Automation Engine object type. element GET_PROCESS_LINE includes a parameter that is also called STR_SUB[STITUTE]_VAR. It makes the same replacements in data sequenceAn internal listing of Console outputs or lines of Variable objects, etc. The lines of a data sequence can be accessed by using a PROCESS loop or the script element GET_PROCESS_LINE. The script elements PREP_PROCESS* generate data sequences. lines.

Examples

The following example stores a script variable's name (&VAR#) in a different variable (&VAR_NOSUB#) by using the & character twice.

If &VAR_NOSUB# is output, the name of the script variable &VAR# is written to the activation protocol. The script element STR_SUB_VAR serves to replace this name by the variable's value.

:SET &VAR#"script variable"
:SET &VAR_NOSUB#"&&VAR# = &VAR#"
:PRINT &VAR_NOSUB#
:SET &VAR_SUB#STR_SUB_VAR(&VAR_NOSUB#)
:PRINT &VAR_SUB#

Output in the activation protocol:

2011-05-06 10:34:04 - U0020408 &VAR# = script variable
2011-05-06 10:34:04 - U0020408 script variable = script variable

 

The second example retrieves a value from the Variable objectAutomation Engine controlled activities and processes are structured in the form of objects. See also: Task VARA.SUB which includes the names of two script variables. These two script variables are created and set.

Only the script variable names are written to the reportA report provides more detailed information about a task's execution or a component. if the Variable object's value is directly output. They are not replaced by their values.

The script element STR_SUB_VAR is used to replace the names of the two script variables by their values.

:SET &VARA# = GET_VAR(VARA.SUB, "SUBVAR")
:SET &VAR1# = "Hello"
:SET &VAR2# = "World"
:PRINT "Content without replacements: &VARA#"
:SET &VARA_SUB_VAR# = STR_SUB_VAR(&VARA#)
:PRINT "Content with replacements: &VARA_SUB_VAR#"

Output without and with STR_SUB_VAR:

2011-05-06 10:34:04 - U0020408 Content without replacements: &VAR1# &VAR2#
2011-05-06 10:34:04 - U0020408 Content with replacements: Hello World

 

See also:

Script element

Description

GET_PROCESS_LINE

Retrieves a data sequence's current line content.

 


Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support

Copyright © 2016 Automic Software GmbH