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 indexing?

Is it possible to change indexing step in labView "For Loop" structure? By
default this value is 1, and I need to make a step value different from "1"
like in C example:

for (index=0; index < 100; index++) {}; // step=1
for (index=0; index < 100; index=index+3) {}; // step=3

--
Sergey Yakovlev, Berlin,
yakovlev@evologics.de
0 Kudos
Message 1 of 5
(2,491 Views)
All you have to do is use the while loop instead of the for loop, you can have any increment value that you want. Terminate the while loop when some test condition is reached.
0 Kudos
Message 2 of 5
(2,491 Views)
Or do the for loop from 0 to 33 (N=34) and use i*3 as index.
0 Kudos
Message 3 of 5
(2,491 Views)
Sergey,
To step by count of 3: Add a shift register pair to your for loop. Initialize the left register to 0. Wire the left shift reigster output and a value of '3' into an Add vi. Send this sum to your right shift register (for use in the next loop) and also send it out as needed for your application. This will be an increment of 3 for each For loop.

I just noticed Dennis has given a workable method with while loops, so now you have 2 options.

Good luck with it, Doug
0 Kudos
Message 4 of 5
(2,491 Views)
Hallo, Sergey,

Du (yakovlev) meintest am 21.09.01 zum Thema for loop indexing?:

> Is it possible to change indexing step in labView "For Loop"
> structure? By default this value is 1, and I need to make a step
> value different from "1" like in C example:

> for (index=0; index < 100; index++) {}; // step=1
> for (index=0; index < 100; index=index+3) {}; // step=3

What about
j:=i*3
and i is incremented by 1

Greetings!
Helmut

Please excuse my gerlish!
0 Kudos
Message 5 of 5
(2,491 Views)