CopyEntries(EntryKeys: Array; DestFolder: Integer);
EntryKeys. Array of copied elements.
DestFolder. Key of the folder, to which elements are to be copied.
The CopyEntries method copies the specified elements to the specified folder.
The EntryKeys array can contain keys of both specific formulas and folders with formulas.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. A calculation block is added in the calculation algorithm. Formulas are created in the calculation block.
Add links to the Algo, Metabase, Ms system assemblies. Add a link to the assembly required for working with calculation algorithm.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObjectDescriptor;
Algo: ICalcObject;
CalcList: ICalcObjectsList;
CalcAlgo: ICalcAlgorithm;
CalcBlock: ICalcBlock;
Folder: IMsCalculationChainFolder;
EntryKeys: Array Of Integer;
Begin
MB := MetabaseClass.Active;
// Get calculation algorithm
MObj := MB.ItemById("ALGORITHM");
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
CalcAlgo := Algo As ICalcAlgorithm;
// Create a list of algorithm objects
CalcList := CalcAlgo.Items.Clone;
CalcBlock := CalcList.Item(0) As ICalcBlock;
// New folder, to which copy formula
Folder := CalcBlock.AddFolder(CalcBlock.Folder);
Folder.Name := "Copy";
// First formula from existing in tree
EntryKeys := New Integer[1];
EntryKeys[0] := CalcBlock.Folder.Contents.Item(0).Key;
CalcBlock.CopyEntries(EntryKeys, Folder.Key);
// Save changes
CalcBlock.SaveObject;
End Sub UserProc;
After executing the example a new folder is created in the tree of calculation block formulas. The first existing calculation block will be copied to this folder formula.
See also: