IMDCalculationInstance.WriteFormulas

Синтаксис

WriteFormulas(Key: IMDCalculationFormulaElementKey; Formulas: IMDCalculationFormulas; [Options: Integer = 0]);

Параметры

Key. Уникальный ключ элемента, по которому необходимо записать формулы.

Formulas. Формулы, которые необходимо записать.

Options. Необязательный параметр, зарезервирован на будущее.

Описание

Метод WriteFormulas осуществляет запись формул по указанному элементу.

Пример

Для выполнения примера предполагается наличие в репозитории многомерного расчета на сервере БД с идентификатором MDCalc_1.

Sub Main;

Var

MB: IMetabase;

MDInst: IMDCalculationInstance;

Formulas: IMDCalculationFormulas;

Formula: IMDCalculationFormula;

FormulaExpression: IMDCalculationFormulaExpression;

Source: IMDCalculationSourceInstance;

Dest: IMDCalculationDestinationInstance;

Slices: IMDCalculationSlicesInstance;

Operand: IMDCalculationFormulaOperand;

DestCoo, SourceCoo: IMatrixCoord;

ElementKey, SourceElKey: IMDCalculationFormulaElementKey;

CoordOperand: IMDCalculationFormulaElement;

ConstOperand: IMDCalculationFormulaConstantValue;

BinaryOperand: IMDCalculationFormulaBinaryOperation;

i: Integer;

Begin

MB := MetabaseClass.Active;

MDInst := MB.ItemById("MDCalc_1").Open(Null) As IMDCalculationInstance;

Formulas := MDInst.CreateFormulas;

Formula := Formulas.Add;

FormulaExpression := Formula.Expression;

Source := MDInst.Sources.Item(0);

Slices := Source.Slices;

//Задать в качестве операнда - координату в источнике

Operand := FormulaExpression.CreateItem(MDCalculationFormulaOperandKind.Element);

SourceCoo := Source.NewCoord;

For i := 0 To Slices.Count - 1 Do

SourceCoo.Item(i) := 0;

End For;

SourceElKey := Source.CoordToKey(SourceCoo);

SourceElKey.FactIndex := 0;

CoordOperand := Operand As IMDCalculationFormulaElement;

CoordOperand.Key := SourceElKey;

FormulaExpression.InsertItem(Operand);

//Задать в качестве операнда - знак "*"

Operand := FormulaExpression.CreateItem(MDCalculationFormulaOperandKind.BinaryOperation);

BinaryOperand := Operand As IMDCalculationFormulaBinaryOperation;

BinaryOperand.BinaryOperation := MDCalculationFormulaBinaryOperation.Mul;

FormulaExpression.InsertItem(Operand);

//Задать в качестве операнда - константу "3.14"

Operand := FormulaExpression.CreateItem(MDCalculationFormulaOperandKind.ConstantValue);

ConstOperand := Operand As IMDCalculationFormulaConstantValue;

ConstOperand.ConstantValue := 3.14;

FormulaExpression.InsertItem(Operand);

//Координата, по которой запишем формулы в приемник

Dest := MDInst.Destination;

DestCoo := Dest.NewCoord;

Slices := Dest.Slices;

For i := 0 To Slices.Count - 1 Do

DestCoo.Item(i) := 0;

End For;

ElementKey := Dest.CoordToKey(DestCoo);

ElementKey.FactIndex := 0;

MDInst.WriteFormulas(ElementKey, Formulas);

End Sub Main;

После выполнения примера будет задана формула для элемента, соответствующего первым элементам измерений приемника данных. Значение по координате в приемнике будет рассчитываться по формуле: Значение по координате в источнике умноженное на 3,14. Данные будут сохраняться по первому показателю приемника.

См. также:

IMDCalculationInstance