Programming Guide : Inter-Frame Communication Techniques : How You Can Communicate with an External Program Using External User Events
 
Share this page          
How You Can Communicate with an External Program Using External User Events
In many computing environments, there are multiple applications running concurrently. Often, it is critical that these applications communicate with each other. For example, in a manufacturing plant, several applications might control the production process, each sending status information such as temperatures and inventory use to a central location. Another application might gather this information continuously, providing a central display that lets workers monitor the machines and tells them when there is a problem. This application communicates with the process applications to update its displays.
OpenROAD applications can communicate with external programs through user events. Just as you can trigger a user event for frames with 4GL code, you can trigger a user event from an external program.
First, you register a frame (or frames) with OpenROAD to receive a particular event. Then, when the event occurs in the external program, the program notifies the OpenROAD application, which adds the user event to the application's native event queue.
When the event reaches the top of the queue, OpenROAD dispatches the event to those frames registered to receive the event. When the event reaches the top of the frame's event queue, OpenROAD executes the event code for the user event.
This feature lets you send a message from the external program to the application notifying it, for example, to update its display or check the database for changes. You can also pass one integer value with the user event, such as a record or file ID. Since both the OpenROAD application and the external program can have open sessions to the same database, this provides a good way for the two programs to interact.
Unless the communicating programs are both OpenROAD applications, using user events to communicate is a one-way process, from the external program to the OpenROAD application. If both programs are OpenROAD applications, each can call a 3GL procedure to communicate with the other.
The basic steps for using external user events are:
1. Use the 4GL RegisterUserEvent method in a frame script to register the external event.
2. In your frame script, write the event block for the external user event. The event block for the user event contains the code that is executed when the external event is triggered.
3. Using the routines described in How You Can Register the External Event), write a 3GL program that sends the event from your external program.
4. Compile your 3GL program and link it as an external program.