STR_SUBSTITUTE_VAR, STR_SUB_VAR

Use the STR_SUBSTITUTE_VAR script function to replace one or several script variable names, that are stored as a string in a different script variable, with the actual variable value. To make the same kind of replacements in data sequence lines, you can use the GET_PROCESS_LINE script function combined with the STR_SUBSTITUTE parameter. For more information, see GET_PROCESS_LINE.

Syntax

STR_SUB[STITUTE]_VAR (Variables)

Parameters

  • STR_SBU[STITUTE]_VAR

    Replaces script variable names with their actual values

  • Variables

    Script variable or string that includes one or several variable names

    Format: script literal or script variable

Return code

String that shows the value of the script variable

Examples

The following example stores the name of a script variable (&VAR#) in a different variable (&VAR_NOSUB#) by using the ampersand (&) character twice. If you print &VAR_NOSUB#, you will see the name of the script variable &VAR# in the activation report. To print the value of the variable, you can use the STR_SUB_VAR script element as shown in the last two lines of this example:

:SET &VAR#"script variable"

:SET &VAR_NOSUB#"&&VAR# = &VAR#"

:PRINT &VAR_NOSUB#

:SET &VAR_SUB#STR_SUB_VAR(&VAR_NOSUB#)

:PRINT &VAR_SUB#

The activation report shows the following result:

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

2022-05-06 10:34:04 - U0020408 script variable = script variable

The following example retrieves a value from the VARA object VARA.SUB, which includes the names of two script variables. The second and third lines of the example create and set these two script variables. Line four prints the script variable names in the activation report, not their values. If you want to print their values, you can use the STR_SUB_VAR script element as shown in the last two lines of this example:

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

2022-05-06 10:34:04 - U0020408 Content without replacements: &VAR1# &VAR2#

2022-05-06 10:34:04 - U0020408 Content with replacements: Hello World

Example

See also: