LabVIEW

cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Auto indexing and wrap around

Hallo,

when I enable AutoIndexing on a While-Loop, the node returns nothing when
the loop reads beyond the end of the array. Is there a way to change this
behaviour so, that the array wraps around and the WhileLoop reads the array
again and again and...

I could do it with a ForLoop nested within a WhileLoop but I love elegant
solutions šŸ˜‰

Regards

Oliver Friedrich
0 Kudos
Message 1 of 3
(2,775 Views)
Hi Oliver,

With Autoindexing it won't work, but manually indexing with index "i mod Arraysize" should do it.....

Not the MOST elegant solution, but it should do the trick.

Regards

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 3
(2,775 Views)
Hello Oliver,

There are several different ways you can do this depending on how you want your output to look. If you would like to repeatedly display each element of the array individually in an indicator, you can use a for loop inside the while loop, with indexing enabled on the for loop but not the while loop. If, instead, you would like to append to your array as the while loop runs so that the array grows in a repeating pattern, you can use either the build array.vi or insert into array.vi in combination with shift registers. I am attaching a simple example VI that demonstrates each of these methods.

I hope this helps!
Jyoti F.
National Instruments
0 Kudos
Message 3 of 3
(2,775 Views)