This one I don't understand. The change that occurs after Accept. I understand showing the execution as it's done by redrawing. That's good and necessary but why does it change to different logic than what I entered? Again using $On to fix it is easy if I can remember to watch for it.
Let's say you have a rung consisting of a single out coil driving C0. That rung evaluates to a single 'OUT C0' instruction, with no driving logic. An OUT literally means: C0 = current value of the boolean stack. We only allow that at the top of a scope, specifically because at the top of the scope, we set the boolean stack to 'TRUE'. So in the case of the OUT C0, it literally evaluates to:
STR TRUE (implied)
OUT C0
Let's say you then insert a new rung above that is a single contact (X0) driving a single coil (Y0). That generates 'STR X0, OUT Y0'. STR X0 means 'push the value of X0 onto the boolean stack', and OUT Y0 means 'set Y0 to value of the boolean stack'. In practice it means Y0 = X0. But here's the issue: the top of the stack is now not TRUE, it's whatever X0 is.
So, your program with both rungs is now:
STR TRUE (implied)
STR X0
OUT Y0
OUT C0
Which is what we redraw. The logic didn't actually change...but the result did. The simple answer would be to eliminate the implied 'STR TRUE' at the top of scope and force contacts into every rung. The thing is that it is an extremely handy construct, especially in stages, so we really want to keep that. It does cause the issue you've observed, and this is only about the 25th time we've heard this...wish we had a better way of dealing with it. Maybe someday we can consider adding the implied 'STR TRUE' (which would actually be STR $On) any time something is inserted in front of a rung with no contact logic. I'm sure it could be done, just not easily.
Does that help, or have I made it worse?
