IMDCalculationExpressionParser.Text

Syntax

Text: String;

Description

The Text property determines text of the formula that must be parsed.

Example

Executing the example requires that the repository contains multidimensional calculation on DB server with the MDCalc_1 identifier.

Sub Main;

Var

MB: IMetabase;

MDInst: IMDCalculationInstance;

Source: IMDCalculationSourceInstance;

Parser: IMDCalculationExpressionParser;

SourceCoord, DestCoord: IMatrixCoord;

SourceKey, DestKey: IMDCalculationFormulaElementKey;

Dest: IMDCalculationDestinationInstance;

Formulas: IMDCalculationFormulas;

Formula: IMDCalculationFormula;

i: Integer;

Begin

MB := MetabaseClass.Active;

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

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

Parser := MDInst.CreateParser;

SourceCoord := Source.NewCoord;

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

SourceCoord.Item(i) := 0;

End For;

SourceKey := Source.CoordToKey(SourceCoord);

Parser.TermKey("Term") := SourceKey;

Parser.Text := "Shift(Term, Year, 1)*3.14";

Parser.Parse;

Dest := MDInst.Destination;

DestCoord := Dest.NewCoord;

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

DestCoord.Item(i) := 0;

End For;

DestKey := Dest.CoordToKey(DestCoord);

Formulas := MDInst.CreateFormulas;

Formula := Formulas.Add;

Parser.Expression.CopyTo(Formula.Expression);

MDInst.WriteFormulas(DestKey, Formulas);

End Sub Main;

After executing the example a new formula for the specified element of the data consumer is created. The formula is obtained through text string parse. The specified data source element is substituted into the expression instead of a term.

See also:

IMDCalculationExpressionParser