AddEx(Assembly: IMetabaseObjectDescriptor, Method: PamAssemblyMethod): Integer;
Assembly. Description of a development environment object that should be included in the list of objects used in a regular report.
Method. Method for connecting a development environment object to a regular report.
The AddEx method connects a development environment object to a regular report included in data entry form and returns index of the connected object in the list.
The list of available objects includes all units, forms, assemblies of the repository.
If on building a data entry form it is not planned to handle table events, then use the PamAssemblyMethod.OnlyReport enumeration as a value of the Method parameter. This method of connecting a development environment object to e regular report reduces time of opening data entry form.
Executing the example requires that the repository contains a regular report with the REPORT identifier and a unit with the MODULE identifier. The unit should be an event handler.
Add links to the Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
DescrHandle: IMetabaseObjectDescriptor;
Assemblies: IPrxAssemblies;
i: Integer;
isFinded: boolean = False;
Begin
MB := MetabaseClass.Active;
// Get regular report
Report := MB.ItemById("REPORT").Edit As IPrxReport;
// Get unit used as event handler
DescrHandle := MB.ItemById("MODULE");
// Get collection of development environment objects connected to regular report
Assemblies := Report.Assemblies;
// Check which development environment objects are connected only to regular report (not to table)
For i := Assemblies.Count - 1 To 0 Step -1 Do
If Assemblies.Item(i).Key = DescrHandle.Key Then
If Assemblies.Method(i) = PamAssemblyMethod.OnlyReport Then
isFinded := True;
Else
// If object is connected to report and table, then remove it from the list
Assemblies.Remove(i);
End If;
End If;
End For;
If Not isFinded Then
// Connect unit only to regular report
Assemblies.AddEx(DescrHandle, PamAssemblyMethod.OnlyReport);
// Specify that unit is event handler
Assemblies.EventsAssembly := Assemblies.Count-1;
Assemblies.EventsClass := "EventsClass";
End If;
// Save changes
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example, the unit is connected to the regular report as an event handler. If development environment objects were connected to the regular report and table before, they will be removed from the list of connected objects.
See also: