Opening Variable in the Modeling Container

Contents

Description

Requirements

Fore Example

Fore.NET Example

Result of the Fore and Fore.NET Examples Execution

Description

Consider the example of opening the variable in the interface of the modeling container.

Requirements

Executing the example requires a modeling container with the MS identifier containing a modeling variable with the VARIABLE identifier.

Add links to the Metabase, Ui system assemblies. For the Fore.NET example add a link to the Fore system assembly.

Fore Example

Sub OpenVariable;
Var
    Mb: IMetabase;
    ObjDes: IMetabaseObjectDescriptor;
    Target: IUiCommandTarget;
Begin
    MB := MetabaseClass.Active;
    // Get modeling variable
    ObjDes := MB.ItemByIdNamespace("VARIABLE", MB.GetObjectKeyById("MS"));
    // Get an object for executing operations with the variable
    Target := WinApplication.Instance.GetObjectTarget(ObjDes);
    // Open modeling variable for edit
    Target.Execute("Object.Edit"Null);
End Sub OpenVariable;

Fore.NET Example

Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.Ui;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    ObjDes: IMetabaseObjectDescriptor;
    RunContext: ForeRuntimeContext;
    WinApp: WinApplicationClassClass = New WinApplicationClassClass();
    Target: IUiCommandTarget;
Begin
    MB := Params.Metabase;
    // Get modeling variable
    ObjDes := MB.ItemByIdNamespace["VARIABLE", MB.GetObjectKeyById("MS")];
    // Get an object for executing operations with the variable
    RunContext := (MB As IForeServices).GetRuntime().Context;
    Target := WinApp.Instance[RunContext].GetObjectTarget(ObjDes);
    // Open modeling variable for edit    
    Target.Execute("Object.Edit"Null, RunContext);
End Sub;

Result of the Fore and Fore.NET Examples Execution

The VARIABLE variable is opened for edit in the interface of the modeling container.

See also:

Examples