LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set a status flag in a FOR loop?

I have a FOR loop inside of a WHILE loop. If, during any iteration of the FOR loop, a certain condition is true, I'd like to set a flag that would tell the WHILE loop to execute again (after the FOR loop has completed). I've tried a number of CASE and SELECT techniques, but the flag value could change on subsequent iterations of said FOR loop. Should I be looking at shift registers? Local variables? Something else?

Regards,
emonk
0 Kudos
Message 1 of 5
(3,982 Views)
Set a shift register initialized to FALSE in the for loop. Then OR the condition with the SR content and write the result to the SR. See picture.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 5
(3,982 Views)
> I have a FOR loop inside of a WHILE loop. If, during any iteration of
> the FOR loop, a certain condition is true, I'd like to set a flag that
> would tell the WHILE loop to execute again (after the FOR loop has
> completed). I've tried a number of CASE and SELECT techniques, but
> the flag value could change on subsequent iterations of said FOR loop.
> Should I be looking at shift registers? Local variables? Something
> else?
>

Use a shift register on the For loop initialized to FALSE and OR the
values together. The output of the right shift register on the For loop
is them wired to the continuation terminal of the While loop.

Greg McKaskle
0 Kudos
Message 3 of 5
(3,982 Views)
Thanks, guys.

That's certainly more elegant & efficient than the workaround I came up with: (see pic). I'll use it.

emonk
0 Kudos
Message 4 of 5
(3,982 Views)
Well you could very well use the boolean array but using "OR Array Elements" instead of "Boolean Array to Number"


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 5
(3,982 Views)