LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW software application

I use formula not in my program. But the do-while loop and for loop do not work. the example simple code is:
outiii=iii;
xaT=111; yaT=222; xbT=333; ybT=444;


do{
if (xaMean>0.55 || yaMean>4) {
xaT= 10;
yaT= 10;
xbT= 10;
ybT= 10;}

} while( iii=10);

why the code can not continuous run?
( i already wired input: iii, xaMean, yaMean)
0 Kudos
Message 1 of 2
(2,674 Views)
It looks like you have two problems.

1. The C syntax of your while statement is wrong. "=" is the assignment operator. (iii=10) always sets iii to a value of 10. "==" is the equivalence operator. (iii==10) tests if iii is equal to 10 but doesn't change the value of iii.

Even after you correct this, your formula won't run in a loop and exit as you expect. See problem 2.

2. The formula node reads the inputs only once: at the start of formula processing. Once LabView starts executing the formula, it doesn't update the input variables. If iii is wired to a control set to 10 initially, the while loop will always see iii as 10, even if the control value changes. So you can't use changes to a front panel control to end a do loop in a formula node.

You c
an use a LabView while loop (rather than a formula node). The while loop also only reads inputs wired from outside the loop once, but you can put the control for iii (or a local variable for it) inside your while loop, so iii will get updated every time through the loop. See the attached example.
0 Kudos
Message 2 of 2
(2,674 Views)