Solution
When using an Event Structure inside a While Loop, it is important to understand that the Event Structure waits for an event before continuing execution. This causes the loop to pause at the Event Structure unless a Timeout case is wired.
Case 1: Numeric control inside the Event Structure (Figure 1)
Execution sequence:
- The While Loop begins its iteration.
- Execution pauses at the Event Structure while waiting for an event.
- The In numeric control triggers a Value Change event.
- The event case for In: Value Change runs.
- The updated value of the In numeric control is passed to the Out 2 numeric indicator.
Case 2: Numeric control outside the Event Structure (Figure 2)
Execution sequence:
- The While Loop begins its iteration.
- The current value of the Out numeric control is passed into the Event Structure.
- Execution pauses at the Event Structure while waiting for an event.
- The Out numeric control triggers a Value Change event.
- The event case for Out: Value Change runs.
- The value from before the event was triggered is passed to the Out2 numeric indicator.
In conclusion, placing the event source inside the Event Structure passes the value that triggered the event, while placing the event source outside the Event Structure passes the value from before the event occurred.