Subscribes an event handler method or procedure to an ABL or .NET class event.
Return type: VOID
Access: PUBLIC
Applies to: ABL or .NET class events
Syntax
[ publisher : ] event-name:Subscribe
( [ subscriber : ] handler-method ) [ NO-ERROR ]
|
[ publisher : ] event-name:Subscribe
( [ subscriber-handle , ] handler-procedure ) [ NO-ERROR ]
|
- [publisher : ]
- The object reference to an ABL or .NET object or the type name of an ABL or .NET class that can publish the instance or static event, respectively. If you do not specify a publisher, it defaults to either THIS-OBJECT when event-name identifies an instance event defined in the current class instance, or to the class type name of the current class definition when event-name identifies a static event defined in the current class hierarchy.
- event-name
- The name of an ABL or .NET event that publisher can publish. At compile time, ABL verifies that event-name is an accessible member of the class referenced by publisher. The event can be an abstract event.
- [subscriber : ]handler-method
- An ABL class-based method that you want to subscribe as a handler for
event-name, where handler-method is the unquoted name of a pure ABL instance or static
method. If specified, subscriber can be either the
object reference to an ABL class instance where handler-method is defined, or the type name of an ABL class where the
static handler-method is defined. If you do not
specify a subscriber, it defaults to either THIS-OBJECT when handler-method identifies an instance method defined in the current class
hierarchy, or to the class type name of the current class definition when handler-method identifies a static method defined in the
current class hierarchy.
Note: The specified
handler-method cannot be a .NET method.
Note that the access mode
(PUBLIC, PACKAGE-PROTECTED, PROTECTED, PACKAGE-PRIVATE, or PRIVATE) of the handler-method definition does not matter to the publisher. For example, you can subscribe a PRIVATE
method of the subscribing class instance as a handler to an event defined and
published by yet another class instance.
The signature of
handler-method does not have to be identical with
the signature defined for event-name, but it must be
run-time compatible. This includes an overloaded method as long as ABL can identify
the signature for a unique overloading that is compatible with the event
signature.
Thus, ABL raises a compile-time error if handler-method:
- Is not accessible to the context where this Subscribe( ) method executes
- Does not have a run-time compatible signature
- Does not have a unique overloading that is compatible with the
event signature
- [subscriber-handle , ] handler-procedure
- A procedure that you want to subscribe as a handler for event-name, where handler-procedure is a character expression that evaluates to the name of an internal procedure. If specified, subscriber-handle is a handle to a persistent procedure, or any other external procedure on the call stack, where the internal procedure is defined. Otherwise, subscriber-handle defaults to THIS-PROCEDURE.
At compile-time, ABL checks this Subscribe( ) method call only to verify that any specified subscriber-handle is a HANDLE data type and that handler-procedure is specified by a character expression. Otherwise, the AVM raises a run-time error if the procedure context specified by subscriber-handle is not accessible or it does not define handler-procedure as an internal procedure.
- NO-ERROR
- The NO-ERROR option is used to prevent the statement from raising ERROR and displaying error messages.