LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to start a Loop from a certain index

Solved!
Go to solution

Hello gents, probably this question has been asked before, I already read the discussion here:

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Smart-Iterators-with-Loops/idi-p/967321#comments

but i didn't understand it quite well.

 

My question is: how can i start a loop from a certain index given an array?

For example, suppose i have an array of 3000 elements and i want to start the loop from the element number 1670 till the final element and put a stop condition on the loop if a certain requirement is fulfilled. How could i do this?

 

Thanks in advance for any answer or help.

0 Kudos
Message 1 of 10
(28,336 Views)

Don't use autoindexing. Get each array element with an Index Array node. As an index, wire the sum of the loop index and your offset (1669 in your example, assuming you mean the 1670th element).

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 10
(28,319 Views)

Sorry, but it is still not very clear to me (i'm new to Labview).

Could you attach a picture or a simple VI with a random created array as an example?

0 Kudos
Message 3 of 10
(28,296 Views)
Solution
Accepted by topic author BonifacioLupo

This is a very trivial example: I'm simply extracting a sub-array from the original data, starting from a given index (you would normally use Array Subset to do this!).

To avoid autoindexing, I right-clicked on the Loop tunnel (where the source array enters the loop) and un-checked Enable Indexing.

 

example.png

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 4 of 10
(28,288 Views)
Solution
Accepted by topic author BonifacioLupo

Start loop from index.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 10
(28,237 Views)

Thank you both pincpanter and Yamaeda i can use this method to solve my problem, so i am basically forced to build a subarray to do this right? And then i should sum the index of my event in the subarray with the indexes i excluded from the original array in order to understand at what index that happens (because i need to know when a certain event happens).

Isn't there something like the Search Waveform palette where i can automatically start "scanning"at a certain index?yeyeyeye.PNG

0 Kudos
Message 6 of 10
(28,206 Views)

Isn't that what the Start Index input is for?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 10
(28,192 Views)

Yes i was asking if there is something similar for arrays without having to use an Array Subset

0 Kudos
Message 8 of 10
(28,188 Views)

Ok my mistake i just found it dumb question, thanks again 😉

0 Kudos
Message 9 of 10
(28,187 Views)
Solution
Accepted by topic author BonifacioLupo

Hi Bonifacio,

 


Isn't there something like the Search Waveform palette where i can automatically start "scanning"at a certain index?

Some array functions like Search1DArray also allow to input a start index…

What's wrong with a simple ADD function to manipulate an index value? (Basically the equivalent to pointer arithmetic in low-level programming languages like Assembler.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 10
(28,178 Views)