PUBLISH statement
Causes an ABL named event to occur.
Note: ABL named events are completely different from the key function, mouse, widget, and direct manipulation events described in the "Handle-based Object Events Reference" section. They are also different from the class events described in the "Class Events Reference" section.Syntax
event-name
FROMpublisher-handle
A procedure or handle representing the procedure or widget to which ABL attributes the named event.The FROM option lets a procedure publish an event on behalf of another procedure or widget. For example, if you want procedure A to publish a named event on behalf of procedure B, setpublisher-handle
to the procedure handle of B.If the FROM option does not appear, ABL attributes the event to THIS-PROCEDURE, the procedure that contains the PUBLISH statement.Note: If the FROM option does not appear and the PUBLISH statement occurs in a nonpersistent procedure that does not publicize its handle, potential subscribers have no way of knowing the handle’s value, and can subscribe to the event only by using the SUBSCRIBE statement’s ANYWHERE option.(parameter
[ ,parameter
] ... )
The parameters, if any, of the named event.As in the RUN statement, you must supply a value for each INPUT and INPUT-OUTPUT parameter and a variable for each OUTPUT parameter.Also, if a named event has one or more parameters, the PUBLISH statement and each subscriber’s local internal procedure (which the SUBSCRIBE statement names and which the AVM runs when the named event occurs) must specify identical signatures-wheresignature
means the number of parameters and the data type and mode (INPUT, etc.) for each.Note: When the named event occurs and the AVM runs each subscriber’s local internal procedure, if the signature of a local internal procedure does not match the signature in the PUBLISH statement, the AVM reports a run-time error. Since the PUBLISH statement runs with an implicit NO-ERROR, errors are stored in the ERROR-STATUS handle.The parameter syntax is identical to that of the RUN statement. For its specification, see the Parameter passing syntax reference entry.ExampleThe following example consists of four procedure files: a driver, a publisher, and two subscribers. The driver,
r-nedrvr.p
, runs the publisher and the two subscribers persistently, then subscribes to the event NewCustomer on behalf of the second subscriber.
The publisher,
r-nepub.p
, publishes the event NewCustomer:
The first subscriber,
nesub1.p
, subscribes to the event NewCustomer:
The second subscriber,
nesub2.p
, already subscribed to the event NewCustomer, cancels all subscriptions:
To start the example, run the driver,
r-nedrvr.p
.Notes
- If a named event has multiple subscribers, the order in which the AVM notifies subscribers is undefined.
- INPUT-OUTPUT parameters can accumulate values from a set of subscribers. When a subscriber receives an INPUT-OUTPUT parameter, it has the value that the previous subscriber set it to. When the publisher receives an INPUT-OUTPUT parameter, it has the value that the last subscriber set it to.
- If a named event with multiple subscribers has OUTPUT parameters, each time a subscriber sets an OUTPUT parameter, the AVM overwrites the previous value. For this reason, Progress Software Corporation recommends that you use OUTPUT parameters with named events only when there is a single subscriber.
- If a named event has multiple subscribers and several subscribers specify a RETURN statement with a return value, the RETURN-VALUE function evaluates to the return value set by the last subscriber.
- The AVM executes the PUBLISH statement with an implicit NO-ERROR option. To find out if any errors occurred, and if so, which ones, use the ERROR-STATUS system handle.
- If
publisher-handle
is a handle, the value of SOURCE-PROCEDURE in each of the subscribers’ internal procedures will be the handle of the procedure that created the widget.See alsoPublish( ) event method, PUBLISHED-EVENTS attribute, SUBSCRIBE statement, UNSUBSCRIBE statement
OpenEdge Release 10.2B
|