LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

the loop doesn't stop until one exact number

Solved!
Go to solution

when i get the table of data via shared variable,the moment i click the button "Ok" it opens 25 worksheet of my workbook

what i want is if my table has just 5 rows full of data, the moment i click "Ok" it opens just 5 worksheet of my workbook.

i think it's an indexation related issue.if anyone could help

thanks

2.png

0 Kudos
Message 1 of 11
(3,194 Views)

You are initializing the array with 25 rows so your array will always hold 25 rows of element which includes empty elements also. Why are initializing the array? If you are not doing that, and if you recieve only the required number of rows the your main for loop will iterate number of times equal to the number of rows.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 11
(3,156 Views)

if i don' t initialize the array,i will not get data in the other columns of my table.i'm using shared variable,and i found that when i send a row of 25 elements nif i don't initialize the array i get them empty

0 Kudos
Message 3 of 11
(3,145 Views)

A simple solution to your problem would be to only run your main loop when there is an unempty row. To do this, you would need to put all your code in the for loop in a case structure. Then add an "empty array" conditional statement at the start of each iteration of the for loop which controls the case structure.

 

Erik S.

Message 4 of 11
(3,111 Views)

where do i have to add conditionnal statement exactely

5.png

0 Kudos
Message 5 of 11
(3,099 Views)

Put the case structure and conditional statement inside the for loop. Then, for each row, the conditional will check if that row is empty and if it is not empty, then it will run your code inside the for loop.

 

Erik S.

0 Kudos
Message 6 of 11
(3,059 Views)

like that

 

5.png

0 Kudos
Message 7 of 11
(3,039 Views)

Yes, this is roughly what I was talking about. Test it out and tweak it but that is the general idea.

 

Erik S.

0 Kudos
Message 8 of 11
(3,030 Views)

Right click where the array enters the for loop and click "Enable Indexing". This option means that when an array is put into the For Loop the loop will automatically step through the items in the array one at a time rather then you needing to index them using the step count as you would for a while loop. You can also use this functionality for exiting while or for loops to automatically generate an array of the values generated within the loop.

0 Kudos
Message 9 of 11
(3,029 Views)

here is the vi after all the modifications, maybe i missed something

15.png

0 Kudos
Message 10 of 11
(3,025 Views)