IPrxDataIslandDimensionLayout.CreateFormulaParser

Syntax

CreateFormulaParser: IPrxDataIslandDimensionLayoutFormulaParser;

Description

The CreateFormulaParser method creates an object which parses formulas specified as character strings.

Example

Executing the example requires a form, a button located on this form and named Button1, the UiReport component with the UiReport1 identifier used as a data source for the ReportBox component. The repository should contain the OBJ_REPORT regular report containing a data area.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

MB: IMetabase;

ReportObj: IMetabaseObject;

Report: IPrxReport;

DIs: IPrxDataIslands;

DI: IPrxDataIsland;

Prop: IPrxDataIslandProperties;

Dim: IDimInstance;

DimProp: IPrxDataIslandDimension;

Layout: IPrxDataIslandDimensionLayout;

RN: IPrxDataIslandDimensionLayoutNodes;

Element: IPrxDataIslandDimensionLayoutNode;

FormulaParser: IPrxDataIslandDimensionLayoutFormulaParser;

Term: String;

Begin

MB := MetabaseClass.Active;

ReportObj := MB.ItemById("OBJ_REPORT").Edit;

Report := ReportObj As IPrxReport;

DIs := Report.DataIslands;

DI := DIs.Item(0).Edit;

    Prop := DI.Properties;

    Dim := DI.Slice.LeftHeader.Item(0).Dimension;

    DimProp := Prop.Dimension(Dim.Dimension);

    DimProp.CustomLayout := True;

    Layout := DimProp.Layout;

    Layout.FitToSelection := False;

    RN := Layout.RootNodes;

    RN.Clear;

    Element := RN.Add;

    Element.DimElement(Dim) := 1;

    Element.Caption := "Element";

    FormulaParser := Layout.CreateFormulaParser;

    Term := FormulaParser.AddTerm;

    FormulaParser.TermType(Term) := LayoutFormulaTermType.Value;

    Element := RN.Add;

    Element.DimElement(Dim) := 1;

    Element.Caption := "Double element";

    FormulaParser.Node := Element;

    FormulaParser.Parse(Term + " * 2");

DI.Save;

Report.Recalc;

ReportObj.Save;

UiReport1.Active := False;

UiReport1.Instance := ReportObj;

End Sub Button1OnClick;

After executing the example two heading elements are created in the first data area of the regular report. The following formula is set for values of the second element: doubled value of the first element.

See also:

IPrxDataIslandDimensionLayout