Table Of Contents

Executing Code Based on an Event

Last Modified: January 24, 2019

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.
  1. (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.
    1. Select the Event Structure. On the Item tab, click Use dynamic events to enable the Dynamic Event Terminals.
    2. Place a Register for Events node on the diagram and wire the output to the input of the Dynamic Event Terminal.
    3. Create diagram code for your event source and wire it to the inputs of Register for Events.
  2. 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.
  3. 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.
  4. Create the code you want the Event Structure to execute when the event occurs. Place this code inside the Event Structure.
  5. (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.
  6. Add additional event cases as required by your application.
    1. Select the Event Structure and click + on the Item tab to add additional event cases.
    2. Repeat steps 2 through 4 for each event case you want to configure.

Recently Viewed Topics