IMsFormulaTermList.Cleanup

Fore Syntax

Cleanup([CleanupVariables: Boolean = false]);

Fore.NET Syntax

Cleanup(CleanupVariables: boolean);

Parameters

CleanupVariables. It determines whether variables corresponding to unused terms should be deleted. Available values:

Description

The Cleanup method removes from collection terms that are not used in the model expression.

Comments

To remove all terms from collection, use the IMsFormulaTermList.Clear method.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier that contains a determinate equation model with the DETERM identifier.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    ModelCont: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    Formula: IMsFormula;
    Determ: IMsDeterministicTransform;
    Operands: IMsFormulaTermList;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Get model
    ModelCont := mb.ItemById("MS");
    Model := mb.ItemByIdNamespace(
"DETERM", ModelCont.Key).Edit As IMsModel;
    
// Get model parameters
    Transform := Model.Transform;
    
// Get model factors
    Formula := Transform.FormulaItem(0);
    Determ := Formula.Method 
As IMsDeterministicTransform;
    Operands := Determ.Operands;
    
// Remove all factors unused in the model expression
    Operands.Cleanup(True);
    
// Save changes
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, all factors that are not used in the model expression will be removed from the model.

Fore.NET Example

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

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    ModelCont: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    Formula: IMsFormula;
    Determ: IMsDeterministicTransform;
    Operands: IMsFormulaTermList;
Begin
    
// Get current repository
    mb := Params.Metabase;
    
// Get model
    ModelCont := mb.ItemById["MS"];
    Model := mb.ItemByIdNamespace[
"DETERM", ModelCont.Key].Edit() As IMsModel;
    
// Get model parameters
    Transform := Model.Transform;
    
// Get model factors
    Formula := Transform.FormulaItem[0];
    Determ := Formula.Method 
As IMsDeterministicTransform;
    Operands := Determ.Operands;
    
// Remove all factors unused in the model expression
    Operands.Cleanup(True);
    
// Save changes
    (Model As IMetabaseObject).Save();
End Sub;

See also:

IMsFormulaTermList