From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

skipping over a for loop

Solved!
Go to solution

Hi Guys,


I feel like this is a dumb problem and know the solution if probably obvious, but I can't seem to find it 🙂

 

I have a for loop with several inputs and outputs in a subvi.  When the subvi is run all the inputs are read, the for loop is skipped over, and the outputs are sent out.  Does anyone have any idea of why the for loop is being skipped?  Everything seems to be wired corretly??..


The vi is attached.

 

Thank you!
Christopher

0 Kudos
Message 1 of 8
(2,910 Views)
Solution
Accepted by topic author Pickering

I cannot open your code due to my having LabVIEW 2009, however here is one thing to check:  Do you have auto-indexing on at all?  Perhaps it is not executing the expected amount of times due to an array being wired as "auto-index" to your for-loop?

 

Another thing to check is try placing an indicator on the output of the "N" and "i" variables of the for-loop (the blue box letters that automatically appear).  This should tell you the "N"umber of times it will iterate and the value of the current 'i'teration.

 

When you use Highlight Execution, do you see it execute any of the code inside the loop?  If so, how many times?  And how many were you expecting?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
Message 2 of 8
(2,907 Views)

Hi, Thanks for the reply. 

The loop is running 0 times. About half of the inputs are auto indexed, and I checked to be sure they were initialized before I ran.  I saved the vi as version 8, so hopefully it will open for you.

 

Thank you!
Christopher

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

I think HappyAsthma has it right here.

 

Check the sizes on each of the arrays in outputcluster3 and LastState.

 

Number of iterations of your for loop will be set by the smallest indexing array size which is likely zero in your case.

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

Pictures of the start and finish of the code are attached.

 

Thank you!
Christopher

Download All
0 Kudos
Message 5 of 8
(2,893 Views)

The VI you posted has empty arrays and will index 0 times.

 

If you're actually passing data in all of your indexing arrays, the loop will work as expected.

 

If there is data that you want to show, do a Set Value to Default on your relevant controls before posting your vi.

0 Kudos
Message 6 of 8
(2,885 Views)

Please run the calling VI with the front panel of this subVI open. unitl the problem occurs. Stop everything and go to the subVI front panel, and do a "edit...make current values the default". save the subVI under a new name and attach it here.

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

Yes he was, I changed the number of values in the array from 0 to 23 and it works!  Thank you!

Christopher

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