Scope

Description: Performs a scope resolution and returns a reference to the requested member within a module or other object.
Returns: Reference
Usage: Script or steady state.
Function Groups: Basic Module
Related to: Variable | ScopeLocal | LocalScope
Format:  Scope(Object, Member[, ScopeLocal])
Parameters:  
Object
Required. Any expression for the object value (module) where Member may be found.
Member
Required. Any text expression for the member name. This must be a simple variable or module. Array references or further scope resolution are not allowed inside the text expression.
ScopeLocal
Optional. A Boolean expression. Defaults to FALSE if missing, invalid or if a non-Boolean is provided.
If set TRUE then the call will not search up the scope tree for name matches.
Comments: This function is the same as the '\' operator, when the '\' operator is used between two operands. (Object\Member). Unlike the backslash operator, the Scope function allows any text string to be used. For members whose names have been obfuscated, Scope() offers the only means of referencing them.
This function may be used as a value, or as an L-value (on the left hand side of an assignment). This function is used to reference one specific occurrence of a variable in a module, from another module.
If the final result is Invalid, this function looks for the presence of backslash (\) characters in the second parameter and parses the result.
When searching for a match, this function ignores variables with the PROTECTED attribute. That is, if such a variable is encountered the search will simply skip over it and continue. Detecting variables with the PROTECTED attribute requires use of the 'Variable' function

Example:

Scope(\Code, "TagName");

Returns a reference to the given tag object, found within the current module.

 

Using ScopeLocal. Start with the following (noting that the initial example could be written more efficiently as "\Code\MyService\Ready").

Scope(\Code, "MyService\Ready");

The Scope operation may not find a variable called "MyService\Ready" in Code, but could find a variable called MyService containing a service object, which itself contains a variable called Ready. This Scope() would return the value of that Ready variable.

If the MyService object does not contain a variable called Ready, but \Code does contain a Ready variable, then Scope will return the value of Code's Ready variable, which may not be what is desired. However, if the ScopeLocal parameter is added and set to TRUE, then it will return Invalid since it will not scope up from MyService to the Ready variable in Code."