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: 

for loop and while loop with empty array input

Solved!
Go to solution

Hi, 

   I got a question with for loop and while loop.

   When an empty array constant (zero element) is connected to For Loop with "enabling index", there are no any interations executed in For Loop. But, If the For Loop is replaced with While loop, no problem.

 

LabVIEW 2010

Message 1 of 5
(4,766 Views)
Solution
Accepted by topic author weitong

Hi,

 

It's ok. I don't see any problem.

 

For the "For loop" when you connect the Array with Indexation the number of Iteration is set to the size of the Array. The Iteration number assigned to N (in your case 10) is ignored.

 

For the "While Loop" the number of Iteration is set by the Boolean Condition and the size of Array is ignored.

 

Paul

Message 2 of 5
(4,756 Views)

Hi weitong,

 

please go through LabVIEW-Basics and the context help to learn about AutoIndexing behaviour:

A FOR loop iterates the maximum number of (size of autoindexing arrays) and (number wired to N)! In your case this will result in zero = max(size of empty array; 10)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 5
(4,755 Views)

 


@GerdW wrote:

Hi weitong,

 

please go through LabVIEW-Basics and the context help to learn about AutoIndexing behaviour:

A FOR loop iterates the maximum number of (size of autoindexing arrays) and (number wired to N)! In your case this will result in zero = max(size of empty array; 10)!


The maximum???  DOn't you mean the MINIMUM?

If the number of elements in array =2

and N terminal is wired to 5

 

"I think" it will execute only 2 times

 

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 4 of 5
(4,745 Views)

Thanks Bjorn,

 

of course it has to be "minimum"...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(4,736 Views)