LabVIEW Idea Exchange

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

Conditional auto-indexing

Status: Completed
Available in LabVIEW 2012

Auto-indexing of arrays in for and while loops are a nice luxury in LabView.  One option that could save much time would be a menu option to turn on conditional indexing, this would expose a boolean terminal under the auto-index icon to select if the current itteration should add the itteration to the array or skip it.  From an execution standpoint there would only be a minor performance hit (could still preallocate max array size on for loops and automatically return used subset).  This could also work for autoindexed in but would have less use that the autoindeded out case.  I know I have built many conditional arrays inside of a for loop and it requires a case selection and a build array making the code less readable and requires time and thought.  It can also be less efficient than a compiler can do.

 

See the example below which would run a for loop and only build array of < 0.1

 

Conditional autoindex.jpg

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
21 Comments
Jim_Kring
Trusted Enthusiast

Great idea!  BTW, there's already an OpenG VI called Conditional_Auto-Indexing_Tunnel that does this:

 

 

This polymorphic VI filters Array In by keeping only those elements where corresponding elements in Elements to Keep are TRUE. 

falkpl
Trusted Enthusiast

Thanks Jim 

I actually use this vi sometimesI usually just drop a shift reg and a case statement around the build arrayDoes the openg handle polymorphism or is this vi only for double floatsI have always wanted to write vis that would adapt to source like the build array functions do but my attempt to follow xNodes was a complete failureIf ni builds this functionality in I wouldnt have to clog up my loops with extra shift registers and unnecessary logicThe labview compiler should also be able to really optomize the code over the build array since the upper bound of the array out (for loop size).

 

Also We could probably bundle this feature with tst suggestion of allowing concatinate arrays on auto-indexing outThen all shift registers and pre-allocating array types would be gone from our code

For backwards compatibility saving these vis in old versions should return the build array and shift register approach.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Jim_Kring
Trusted Enthusiast

Hi falkpl,

 

Yes the OpenG  Conditional Auto-Indexing Tunnel is polymorphic, but could definitely use some kind of better type adaption like LabVIEW's native polymorphism.

 

Cheers,

JimboH
Member
Perhaps you could also switch the location of the boolean input (below or above the terminal), or have some other means of indicating concatenation before or after the current array.
jdoyle
Member
This is a great idea!  We have countless places that would be hugely cleaner with this feature.  And it would probably improve performance, too.
Greil
Member

What a great idea, but it is not yours! Almost the same example.

 

May 2008: http://lavag.org/topic/7574-conditional-append/page__p__44719&#entry44719 

 

Anyway, i want NI to implement this, so i click Kudos! 

muks
Proven Zealot
Great idea and i suppose it will make it perform better as well..
Rob_Calhoun
Member
I applied Kudos to this thread and cross-posted comments to another version of the same thing.
Ray.R
Knight of NI

I'm sure most people have implemented their own workarounds for a similar solution.

It would be great to have this feature in LabVIEW. 

 

Kudos!

viScience
Active Participant

Yes, I often use the openg version.  Having it built into LV would be awesome!