Value: Variant;
The Value property determines parameter value to be used in calculation.
Executing the example requires the KONT_MODEL modeling container. The custom method template that contains two parameters is created in the container. The container also includes the USER_VAR and USER_VAR_FACTOR modeling variables that will be used as output and factor ones respectively.
Add links to the Metabase and Ms system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MDesc: IMetabaseObjectDescriptor;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
Varr: IVariableStub;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
UserTr: IMsUserTransform;
TransVar: IMsFormulaTransformVariable;
Params: IMsUserMethodParams;
Begin
MB := MetabaseClass.Active;
MDesc := Mb.ItemById("KONT_MODEL");
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "USER_MODEL";
CrInf.Name := "User_Model";
CrInf.Parent := MDesc;
MObj := Mb.CreateObject(CrInf).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
//Output variable
Varr := MB.ItemByIdNamespace("USER_VAR", MDesc.Key).Bind As IVariableStub;
Trans.Outputs.Add(Varr);
VarTrans := Trans.Outputs.Item(0);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Trans.CreateSelector;
Selector.Slice := Slice;
Formula := Trans.Transform(Selector);
Formula.Kind := MsFormulaKind.User;
Formula.Level := DimCalendarLevel.Year;
UserTr := Formula.Method As IMsUserTransform;
UserTr.Template := (MDesc.Bind As IMsModelSpace).UserMethodTemplates.Item(0);
//Factor
Varr := MB.ItemByIdNamespace("USER_VAR_FACTOR", MDesc.Key).Bind As IVariableStub;
Trans.Inputs.Add(Varr);
TransVar := Model.Transform.Inputs.Item(0);
UserTr.Explanatories.Add(TransVar.SlicesTree(Null).CreateSlice(1));
Params := UserTr.Params;
Params.Item(0).Value := 10;
Params.Item(1).Value := 100;
MObj.Save;
End Sub UserProc;
After executing the example a model is created in the modeling container. For model calculation the custom method implemented in the unit, to which the first modeling container template refers, is used. The output variable and a factor are added to the model, and the parameter values are set.
See also: