IDimMacroGroupPrimitive.SendGroupAsParam

Syntax

SendGroupAsParam: Boolean;

Description

The SendGroupAsParam property determines whether macro uses an element group.

Comments

Available values:

If the property is set to True, the function in macros must have the following signature:

Public Shared Function <procedure name>(<dictionary instance>: IDimInstance; <current group of elements>: IDimElementGroup): IDimSelection;
Begin
    
End Function <procedure name>;

Example

Executing the example requires that the repository contains a dictionary with the DICT_GROUP identifier containing a group of elements. It is also supposed to have a unit with the MACRO_DIM_EL_GROUP identifier containing the Primitives class which implements the GroupMacro function. This function will be used as a macro generating a group of elements. The MACRO_DIM_EL_GROUP unit code is given below.

Add links to the Dimensions, Metabase system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Desc: IMetabaseObjectDescriptor;
    Group: IDimElementGroup;
    i: Integer;
    MacroPrimitive: IDimMacroGroupPrimitive;
Begin
    // Get current repository
    mb := Metabaseclass.Active;
    // Get dictionary
    Desc := mb.ItemById("DICT_GROUP").Children.Item(0);
    // Check whether the first child object of the dictionary is an element group
    If Desc.ClassId = 1029 Then
        // Get a group of elements for editing
        Group := Desc.Edit As IDimElementGroup;
        // Change name of element group
        (Group As IMetabaseObject).Name := "Elements generated by macro";
        // Remove all selection primitives from group
        i := Group.Count;
        Repeat
            i := i - 1;
            Group.RemovePrimitive(i);
        Until i = 0;
        // Add a primitive being a macro to the group
        MacroPrimitive := Group.AddPrimitive(SelectionGroupType.Macro) As IDimMacroGroupPrimitive;
        // Specify that macro will use group of elements
        MacroPrimitive.SendGroupAsParam := True;
        
// Specify unit
        MacroPrimitive.Module := mb.ItemById("MACRO_DIM_EL_GROUP");
        
// Specify macro binding
        MacroPrimitive.ModuleMacro := "Primitives.GroupMacro";
        
// Save changes in selection group
        (Group As IMetabaseObject).Save;
    End If;
End Sub UserProc;

Code of the MACRO_DIM_EL_GROUP unit.

Add link to the Dimensions system assembly.

Class Primitives: Object
    
    // Macro to generate dictionary element selection
    Public Shared Function GroupMacro(Dimension: IDimInstance; DimGroup: IDimElementGroup): IDimSelection;
    Var
        DictSelection, GroupSelection: IDimSelection;
        i: Integer;
    Begin
        // Create dictionary element selection
        DictSelection := Dimension.CreateSelection;
        // Include three dictionary elements to the selection
        DictSelection.SelectElement(0False);
        DictSelection.SelectElement(2False);
        DictSelection.SelectElement(5False);
        // Get selection of element group
        GroupSelection := DimGroup.Selection;
        // Include element group selection to the dictionary element selection
        For i := 0 To GroupSelection.SelectedCount - 1 Do
            DictSelection.SelectElement(GroupSelection.Element(0), False);
        End For;
        // Return created dictionary element selection
        Return DictSelection;
    End Function GroupMacro;
    
End Class Primitives;

After executing the example the Elements Generated by the Macro group generated by the MACRO_DIM_EL_GROUP macro will be available in all objects using the MACRO_DIM_EL_GROUP dictionary as a dimension.

See also:

IDimMacroGroupPrimitive