Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Bolt on November 26, 2024, 02:12:46 PM
-
Is there a way to "freeze" a FOR/NEXT loop? Say I have a loop monitoring some bits. If a bit becomes TRUE, I'd like to keep the pointer value where it is, end the loop, and let the rest of the PLC's logic proceed as normal. It's not quite a BREAK, as next scan I'd like the loop to continue with it's previous pointer value. Is this even a thing?
-
There is no "enable" leg on a FOR/NEXT loop.
What you can do, is emulate a FOR/NEXT using WHILE/WEND where you can conditionally terminate the loop with conditions other than Count < Preset (e.g. EnableLoop AND Count < Preset)
-
Ah, I hadn't thought of using WHILE/WEND here. I am considering doing a COPY Pointer to Holding and BREAK, then at the start of the loop IF Holding>0, COPY Holding to Pointer. That should work I think.
-
I forgot...
FOR/NEXT behavior is Count <= Preset
;D
-
True, but no big deal here. For my application today it worked to COPY
Pointer Count to Holding, and BREAK. At the top of the loop I COPY Holding back to Count so it picks up where it left off until I reset the Holding.