:RESOLVE

Use the :RESOLVE script statement to resolve variables in a string and assign the result to a script variable. It combines the behaviour of :SET and the RESOLVE_VAR function, and can resolve any of the following variable types:

  • PromptSet variables

  • System variables

    Note: System variables are only resolved if they have been used within the object before the :RESOLVE statement is called. The script processing engine only includes system variables it has already encountered during pre-processing.

  • Script variables

  • VARA objects

Syntax

: RESOLVE script variable = string

Parameters

Parameter Description Format
script variable Script variable to set to the resolved value. If the system cannot resolve a variable, it remains unchanged and the resulting value is assigned to this variable. n.a.
string String to resolve. Can contain any number of variables of any type. script literal

Important Considerations

Key considerations include:

  • Undefined variables cause a runtime error. Variables with no value resolve to a single space (' ').
  • :RESOLVE can perform multiple rounds of variable resolution. First, it replaces escaped ampersands (&&) with a single ampersand. Then it resolves variables — any string starting with an ampersand followed by at least one valid variable name character and at least one invalid one. These steps repeat until no escaped ampersands or unresolved variables remain.
  • :RESOLVE can resolve up to two levels of nesting. To resolve deeper nesting, add additional :RESOLVE statements. See the depth of resolution example below.

Examples

An SQLI VARA object (VARA.SQLI_TEST) returns version and build numbers via SQL. The following script resolves the VARA object in a string and assigns the result to a script variable.

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

: PRINT &ret#

The activation report shows:

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. The :RESOLVE statement specifies the key and value column. The value stored in the VARA object is the phrase this is the main key.

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

: PRINT &var#

The activation report shows:

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

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

The following example demonstrates two-level nesting resolution. The first :RESOLVE resolves the inner variables &Env# and &SysName_EXP#. The second resolves the outermost variable &CompanyName_AE_EXP#.

: 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 activation report shows:

U00020408 System: MyCompany_AE_EXP

See also: