LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop in for loop

hello,

 

i have a problem with the following:

Neues Bild (1).JPG

 

it starts and doesnt end. only the first "m" and "b" gets inside the while loop. afer "=" there is false. Why is this while loop standing still?

0 Kudos
Message 1 of 8
(2,926 Views)

How do you know it is standing still ?

What if it can't find a true, how do you stop it ?

 

0 Kudos
Message 2 of 8
(2,916 Views)

The stop condition is that your number has to equal zero.  You did not get a zero so the loop does not stop.  You could try less than or equal to zero for a stop condition.  Put a probe on the number feeding into your condition.

0 Kudos
Message 3 of 8
(2,915 Views)

ok, that could be the reason.

Good idea with the less than or equal to zero for the stop condition.

But this would only function, if the line-value begins with a value/values less than the values of the comparing array.

So i have to set a case structure for this i think.

 

 

0 Kudos
Message 4 of 8
(2,902 Views)

You could also make it without a while loop:

 

test.png

0 Kudos
Message 5 of 8
(2,900 Views)

@dkfire wrote:

You could also make it without a while loop:

 

test.png


One thing to note about the above code. If the input arrays are not the same size the loop will only run a number of times equal to the length of the shortest array. If an empty array was input the loop would not run.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 8
(2,894 Views)

You can also use the in range (on the comparison palette) and define the upper and lower limits of when you want it to stop.

0 Kudos
Message 7 of 8
(2,893 Views)

this code looks nice. instead of searching for the 0 i could square the values in the array and search for Min.

I will try this tomorrow. I think there are some other mistakes in my vi on top, because "array with x values" and "array with indizes" (the lower lines) are on 0 when the program runs and nothing varies. But the first point has the coordinates y=0, x=90.

edit: the arrays have the same length.

0 Kudos
Message 8 of 8
(2,882 Views)