IUnitsDimInstance.BasisByElement

Syntax

BasisByElement(Element: Integer): Integer;

Parameters

Element. Index of dictionary element.

Description

The BasisByElement property returns index of basic measurement unit for element.

Comments

Basic unit of measure is unit with 1 scale of the element measure.

Example

Executing the example requires that the repository contains a time series database with the FC identifier. Add links to the Metabase, Cubes and Dimensions system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Cat: IMetabaseObject;
    Inst: IRubricatorInstance;
    UnitsDim: IDimInstance;
    Units: IUnitsDimInstance;
    Elements: IDimElements;
    i, j, Basis: Integer;
    El: Integer;
    bIsUnit: Boolean;
Begin
    Mb := MetabaseClass.Active;
    Cat := Mb.ItemById("FC").Bind;
    Inst := Cat.Open(NullAs IRubricatorInstance;
    UnitsDim := Inst.UnitsDimension;
    Elements := UnitsDim.Elements;
    Units := UnitsDim As IUnitsDimInstance;
    For i := 0 To Elements.Count - 1 Do
        El := Elements.Elements.Element(i);
        bIsUnit := Units.IsUnit(El);
        If Not bIsUnit Then
            Debug.WriteLine(Elements.Name(El));
            Basis := Units.BasisByElement(El);
            For j := 0 To Elements.Count - 1 Do
                El := Elements.Elements.Element(j);
                bIsUnit := Units.IsUnit(El);
                If (bIsUnit) And (Units.BasisByElement(El) = Basis) Then
                    Debug.WriteLine("  " + Elements.Name(El));
                    Debug.WriteLine("    scale: " + Units.Scale(El).ToString);
                    Debug.WriteLine("    measure: " + Units.MeasureByElement(El).ToString);
                    Debug.WriteLine("    key: " + Units.KeyByElement(El));
                End If;
            End For;
        Else
        End If;
    End For;
End Sub UserProc;

After executing the example the hierarchy of units of the time series data base is displayed in the output. Every non-base element contains key, measure value and scale.

See also:

IUnitsDimInstance