An event occurs when a signal changes, not on every scan while it stays true. Compare the current sensor with a stored previous state to generate a one-scan pulse. Update that memory after computing the pulse. The held-input test distinguishes an edge detector from a direct contact, while a second transition proves it rearms.
A photoeye may remain covered by one carton for several scans. The pulse marks its arrival once. After the carton leaves, the previous-state bit returns false and the next carton can produce another pulse. Writing memory first erases the transition before the pulse logic can observe it.
Read the tag list and the requested sequence before editing.