04-21-2010 11:38 AM
Hello everyone,
I need some general programming advice to help my VI run more efficiently. I have a 2d array in which the program cycles through each point and compares the value to the surrounding points. The user can select the cell range range to inspect, so if the user selects 1, then it will compare the (0,0) point to all the cells within one cell. If the user selects 2, then all the cells within a 2 cell range, and so on. If the (0,0) point is greater than all the points around it, then it writes that point to an array.
I made more notes in the VI to explain what's going on, but I think the program would run more efficiently if I could stop a for loop from running as soon as it finds a false condition, ie the (0,0) is not greater than one of the surrounding points. As it is right now, it compares it to all the points around it, writes TRUE/FALSE to an array, then checks to see if all the conditions are TRUE. That takes a long time if the user selects a value of 8, for instance. It would minimize a lot of processing time if it just kicked to the next point as soon as it found a FALSE condition.
Any other advice would be appreciated as well. Trying to be a more efficient programmer!
Thanks!
Alex
I did not attach the data file because it is too big.
Solved! Go to Solution.
04-21-2010 02:01 PM
right click at the dege of your for loop and select conditional terminal, this will work just like the terminal of a while loop, you can terminate your loops early just as you want to. I love this because you get the best of both worlds with little change to the code.
It is not avaliable in earlire versions of labview (pre 8.5?)
04-21-2010 02:06 PM
In versions before the invention of the For Loop with conditional stop terminal, you can do this, but you have to wire it up as a while loop where you stop when your condition is True, OR when the i terminal is equal to the size of the incoming array - 1.
04-23-2010 03:33 PM