GetModuleContext

(Engine-Level Function)

Description:

Given a module-in-context, this function returns the parent object of an instance of that module when it is launched or called.

Warning: This function should be used only by advanced programmers.
Returns: A reference to the context module where scope of the given module should be resolved.
Usage: Script or steady state.
Function Groups: Variable
Related to: GetInstance | GetModuleText
Format: \GetModuleContext(ModuleInContext)
Parameters:  
ModuleInContext
Required. A module-in-context object.
Comments: A "module-in-context" is a reference to a module associated to a specific context, or module instance. Refer to value type 49 in VTScada Value Types.

Examples:

A somewhat contrived example...

[
  Me;
  ChildModuleObj;
  Context;
  MyModuleInContext;
  Graphics Module;
]

Main [
  If Watch(1);
  [
    Me = GetInstance(self(), 0);
    MyModuleInContext = Me.Graphics;
    Context = GetModuleContext(MyModuleInContext); { Context == ParentObject }
    ChildModuleObj = MyModuleInContext();  { Context == ParentObject(ChildModuleObj) }
  ]
]

<
Graphics
()
[ ]
Main [

]
>

"Me" will hold a reference to the module shown above, which in this in this case is Overview. (The overview page)

MyModuleInContext will hold a reference to the Graphics submodule

Context will be the same as Me.

ChildModuleObj will be the same as MyModuleInContext.