IMsMetaModelVisualController.RenameVariable

Fore Syntax

RenameVariable(EntryKey: Integer; Name: String): Boolean;

Fore.NET Syntax

RenameVariable(EntryKey: integer; Name: string): boolean;

Parameters

EntryKey. V.ariable key.

Name. The required name of the variable.

Description

The RenameVariable method renames the specified internal metamodel variable.

Comments

Available values:

To create internal variable, use IMsMetaModelVisualController.CreateVariable method.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the FILLMODEL identifier. This problem must contain an internal metamodel containing an internal time series database and a model.

Add links to the Metabase, Ms system assemblies.

Sub RenameVariable;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    Varable: IMsCalculationChainVariable;
    pr: IMsProblem;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    // Get modeling problem
    pr := mb.ItemByIdNamespace("FILLMODEL", MsObj.Key).Bind As IMsProblem;
    // Get metamodel
    Meta := pr.MetaModel;
    MetaVisual := Meta.VisualController;
    //nbsp;Getnbsp;the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item(i).Type = MsCalculationChainEntryType.Variable Then
            Varable := ChainEn.Item(i) As IMsCalculationChainVariable;
            MetaVisual.RenameVariable(Varable.Key, Varable.Name + "_");
        End If;
    End For;
End Sub RenameVariable;

After executing the example all internal variables of the specified problem will be renamed.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    Varable: IMsCalculationChainVariable;
    pr: IMsProblem;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
Begin
    mb := Params.Metabase;
    // Get modeling container
    MsObj := mb.ItemById["MS"];
    // Get modeling problem
    pr := mb.ItemByIdNamespace["FILLMODEL", MsObj.Key].Bind() As IMsProblem;
    // Get metamodel
    Meta := pr.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item[i].Type = MsCalculationChainEntryType.mccetVariable Then
            Varable := ChainEn.Item[i] As IMsCalculationChainVariable;
            MetaVisual.RenameVariable(Varable.Key As integer, Varable.Name + "_");
        End If;
    End For;
End Sub;

See also:

IMsMetaModelVisualController