We will perform this function by using one Loop Enabled sequence that continuously checks the inputs and opens/closes the doors if necessary.
The figure below shows the events of our sequence, OpenCloseDoors.
This sequence loops every 10 frames and updates the state of the doors based upon the
switch inputs (DoorOpenInput and DoorCloseInput) and the script open/close
flag (DoorFlag). The sequence first checks if either input is on. If the operator
has moved the switch to the Open position, the doors should be opened. Similarly,
if the operator has moved the switch to the Close position, the doors are
automatically closed without regard to DoorFlag. Finally, if the doors are in the Auto position, the status of DoorFlag is checked. If DoorFlag is "on" the
doors are opened, and vice versa.
Using flags as "permission" outputs allows a separate
sequence to monitor the status of operator controls, check the flag, and perform the
desired action ("grant permission"), if possible. As you can see, we have saved
considerable Ladder Logic programming (and perhaps an entire PLC) by utilizing one
sequence, one flag, and two inputs to control our automatic doors.