CalendarLevelIndex(Level: DimCalendarLevel): Integer;
Level - calendar level.
The CalendarLevelIndex property returns index for selected calendar level.
Executing the example requires that repository contains a calendar dictionary with the DICT_CALEND identifier.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
CalDim: ICalendarDimension;
UserAttrs: ICalendarDimAttributes;
UserAttr: ICalendarDimAttribute;
LevInd: Integer;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("DICT_CALEND").Edit;
CalDim := MObj As ICalendarDimension;
UserAttrs := CalDim.Attributes;
UserAttrs.Clear;
UserAttr := UserAttrs.Add;
LevInd := CalDim.CalendarLevelIndex(DimCalendarLevel.Root);
UserAttr.Format(LevInd) := "Calendar";
LevInd := CalDim.CalendarLevelIndex(DimCalendarLevel.Year);
UserAttr.Format(LevInd) := "Year/YY";
LevInd := CalDim.CalendarLevelIndex(DimCalendarLevel.HalfYear);
UserAttr.Format(LevInd) := "SA half-year";
LevInd := CalDim.CalendarLevelIndex(DimCalendarLevel.Quarter);
UserAttr.Format(LevInd) := "QA quarter";
LevInd := CalDim.CalendarLevelIndex(DimCalendarLevel.Month);
UserAttr.Format(LevInd) := "ML month";
LevInd := CalDim.CalendarLevelIndex(DimCalendarLevel.Day);
UserAttr.Format(LevInd) := "Day: DD";
UserAttrs.Name := UserAttr;
MObj.Save;
End Sub Main;
After executing the example a new custom attribute is added to the dictionary. Elements of all levels are displayed with names of various formats (left), that differ from the standard ones (right):
See also: