ICalcObject.CreateCopy

Syntax

CreateCopy(OpenForEdit: Boolean): ICalcObject;

Parameters

OpenForEdit. Allow or deny to edit calculation algorithm object.

Description

The CreateCopy method creates a copy of calculation algorithm object.

Comments

Available values of the OpenForEdit parameter:

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. The calculation algorithm should contain configured objects.

Add links to the Algo system assembly. Add a link to the assembly required for working with calculation algorithm.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObjectDescriptor;
    CalcAlgo: ICalcAlgorithm;
    Objects: ICalcObjectsList;
    Algo, CalcAlgObj, CopyObj: ICalcObject;
Begin
    MB := MetabaseClass.Active;
    // Get calculation algorithm
    MObj := MB.ItemById("ALGORITHM");
    Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
    CalcAlgo := Algo As ICalcAlgorithm;
    // Create a copy of the first block
    Objects := CalcAlgo.Items;
    CalcAlgObj := Objects.Item(0);
    CopyObj := CalcAlgObj.CreateCopy(True);
    CopyObj.Name := "Block copy";
    Objects.Add(CopyObj);
    // Save changes
    CopyObj.SaveObject;
    Algo.SaveObject;
End Sub UserProc;

After executing the example, a copy of the first existing object will be created in the calculation algorithm.

See also:

ICalcObject