:RESOLVE

Use the :RESOLVE script statement to resolve variables contained in a string. This script statement works like a combination of a :SET statement and the RESOLVE_VAR function. The system tries to resolve any type of variable:

Syntax

: RESOLVE script variable = string


Note: If the system cannot resolve a variable, the variable remains unchanged. The resulting value is assigned to the variable.

How Variable Resolution Works

:RESOLVE can perform multiple rounds of variable resolution:

  1. Replace escaped ampersands (&&) with a single ampersand

  2. Resolve variables for any string with an ampersand and followed by the following:

    • At least one character that can be part of a variable name
    • At least one character that cannot be part of a variable name

These steps repeat until no escaped ampersands and no unresolved variables remain.

Undefined variables cause a runtime error. Variables with no value resolve to a single space (' ').

Depth of Resolution

:RESOLVE can resolve up to two levels of nesting. To resolve more levels of nested variables, add additional :RESOLVE commands to resolve the contents of the variable. For example:

:SET &Env# = "EXP"

:SET &SysName_EXP# = "AE_EXP"

:SET &CompanyName_AE_EXP# = "MyCompany_AE_EXP"

:RESOLVE &System# = "&&&&CompanyName_&&SysName_&Env###"

:RESOLVE &System# = "&System#"

:PRINT "System: &System#"

The first :RESOLVE command resolves the inner two variables, &Env# and then &SysName_EXP#. The second :RESOLVE command then resolves the outermost variable &CompanyName_AE_EXP#. The result looks like this:

U00020408 System: MyCompany_AE_EXP

Examples

Assume that an SQLI VARA object (VARA.SQLI_TEST) includes SQL that returns version and build numbers. The script below resolves the SQLI VARA object in a string. The script assigns the resulting text as the value of a script variable called &ret#.

:RESOLVE &ret# = "This is version {VARA.SQLI_TEST}"

:PRINT &ret#

The second script line prints the value of the script variable in the activation report:

2014-11-18 11:50:22 - U00020408 This is version 11.0.0+build.2751

The following example resolves a static VARA object called VARA_RESOLVE and prints the value in the activation report. The parameters in the :RESOLVE statement specify the key and value in the VARA object. The value stored in the VARA object is a phrase (this is the main key).

:RESOLVE &var# = "{VARA_RESOLVE,key1,1}"

:PRINT &var#

The script prints the following lines in the activation report:

2014-11-18 17:50:32 - U00020408 {VARA_RESOLVE,key1,1}

2014-11-18 17:50:32 - U00020408 this is the main key

See also: