# The program demonstrates the general event handling pattern # and some features of the EXT programming language. # When releasing the case opening button, # the relay 1 will be switched. proc main() # the main routine (entry point) { var e = $get_event_id(); # getting the event to handle if e == $EVT_INIT { # processing of the initialization $set_event_mask($EM_SYSTEM); # enabling the system events } else if e == $EVT_CASE_OPEN { # processing of the case opening toggle(1); # switching the relay 1 } } proc toggle(n) # the output control routine { # n - output number var s = $get_output_state(n); # getting the current state $set_output_state(n, !s); # setting the inverse state }