The code you have will energise that coil when it detects a non zero, however, if there is a zero then on the next itteration it will turn it back off so all would have to be non zero to energise the coil,
Not quite, although perhaps I am misunderstanding @parky's query here.
The output coil is executed
exactly once for every scan, and that coil is executed at the end of the loop I.e. After the loop terminates.
The key thing to understand is that the value assigned via the coil is dependent on
how the loop terminates, and by terminate I mean the jump backwards to Q2 does
not occur. There are two possible causes of such a termination (funky behavior of @modiconguy's system notwithstanding):
1) the loop terminates because the loop found a zero value at some index, 0 to 18, in the array. This occurs when the NEQ evaluates to FALSE, and when that occurs, the loop index is in the range [0:18] inclusive, i .e. a valid index into the array. Note that even though that FALSE result terminates the loop, all of the instructions in the loop execute
one last time, albeit with their input rugs
having a value of FALSE. So the coil instruction writes a zero to its boolean operand NO_ZEROS_IN_N26.
2) The loop terminates because the loop index exceeds the final array element index of 18, because none of the array valles were zero. In this case, the NEQ evaluates to TRUE, and it is the LT instruction that evaluates to FALSE, preventing the jump backwards to Q2. The execution flow drops through to the coil, for the first time during the current scan, and assigns a 1 to NO_ZEROS_IN_N26, because the input rung to that coil has the TRUE value from the NEQ
instruction's last (19th) execution with an index of 18.
So as noted above, that coil executes exactly once per scan i.e. once per loop, no matter how many iterations the loop executes.