Params: IMsModelParams;
The Params property returns the collection of calculation algorithm object parameters.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier. Calculation blocks are created and set up in the calculation algorithm. The repository should also contain a dictionary with the CALENDAR identifier used by calculation block consumer and sources.
Add links to the Algo, Metabase, Ms, Transform system assemblies. Add links to the assemblies required for working with calculation algorithms.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObjectDescriptor;
Algo, CalcBlock: ICalcObject;
List: ICalcObjectsList;
CalcAlgo: ICalcAlgorithm;
Block: ICalcBlock;
i: integer;
Params: IMsModelParams;
Param: IMsModelParam;
Dict: IMetabaseObjectDescriptor;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("ALGORITHM");
// Get dictionary
Dict := MB.ItemById("CALENDAR");
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
// Rename algorithm
Algo.Descriptor.Name := "Algorithm (with parameters)";
Params := Algo.Params;
// Add a new parameter
Param := Params.Add;
Param.Name := "Parameter 1";
Param.ParamType := TsParamType.Selection;
// Set dictionary, which values are used as parameter values
Param.LinkedObject := Dict;
Param.SelectionMode := SelectionModeEnum.SingleSelect;
// Save metamodel
(Algo.MetaModel As IMetabaseObject).Save;
CalcAlgo := Algo As ICalcAlgorithm;
// Create a list of algorithm objects
List := CalcAlgo.Items;
// Set up list of objects
For i := 0 To List.Count - 1 Do
CalcBlock := List.Item(i);
If CalcBlock.Type = CalcObjectType.CalcBlock Then
Debug.WriteLine(CalcBlock.Name);
Block := CalcBlock As ICalcBlock;
// If algorithm is opened for edit, calculation objects can be edited
If CalcAlgo.IsEdited Then
// Add a suffix for all algorithm calculation blocks from calculation chain
Block.Name := Block.Name + "(with parameter)";
// Add a parameter to each calculation block
Param := Block.Params.Add;
Param.Name := "Calculation block parameter";
Param.ParamType := TsParamType.Selection;
Param.LinkedObject := Dict;
Param.SelectionMode := SelectionModeEnum.SingleSelect;
Block.SaveObject;
End If;
End If;
End For;
// Save changes
Algo.SaveObject;
End Sub UserProc;
After executing the example, various settings of calculation algorithm and calculation block will be changed:
Object names will be changed.
Parameters will be added to calculation algorithm and calculation blocks structure.
See also: