To execute code based on an event, you must configure the
Event Structure
to handle events.
Before you configure events for the
Event Structure
to handle, review the
Recommendations for Event-Driven Programming. Complete the following steps to configure an
Event Structure
case to handle events.
-
(Optional) If you want to configure the
Event Structure
to handle an external I/O event or a programmatically generated event, you first must dynamically register that event.
-
Select the
Event Structure. On the
Item
tab, click
Use dynamic events
to enable the
Dynamic Event Terminals.
-
Place a
Register for Events
node on the diagram and wire the output to the input of the
Dynamic Event Terminal.
-
Create diagram code for your event source and wire it to the inputs of
Register for Events.
-
Click the event selector label at the top of the
Event Structure, to view the list of available event sources from which you can choose.
-
Select one or more event sources for which you want to respond. Then select an event type for each event source.
The event case you configure appears as a selection option in the event selector label at the top of the
Event Structure, and the
Event Data Node
displays the data common to all events handled in that case.
-
Create the code you want the
Event Structure
to execute when the event occurs.
Place this code inside the
Event Structure.
-
(Optional) Use a Timeout event to configure an
Event Structure
to wait a specified amount of time for an event to occur.
If no event occurs before the specified amount of time passes, the
Event Structure
stops handling events.
-
Add additional event cases as required by your application.
-
Select the
Event Structure
and click
+
on the
Item
tab to add additional event cases.
-
Repeat steps 2 through 4 for each event case you want to configure.