LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace Array Subset with Index > Size

Solved!
Go to solution

Dear all,
 
Whenever I use the Replace Array Subset function and one of the last elements is missing (like in a Cursor List) the function does nothing (this is intended by LabView). But I really would like to insert this element into the desired position. So I make a subvi doing it: Checking the size, filling in the missing elements and then replacing it as I intended. And a week later I have the same problem with a different array data structure and can build a new subvi or add a polymorphic case....
 
May I wish for an option in the Replace Array Subset vi to allow this? Or am I doing it wrong?

LV 2018
0 Kudos
Message 1 of 5
(1,548 Views)

Hi Dom,

 


@DomLabView wrote:

May I wish for an option in the Replace Array Subset vi to allow this? Or am I doing it wrong?


How often do you need to replace non-existing array elements?

And why do you access them by using a fixed index?

 

Hint: When using autoindexing loops you almost never need to use ReplaceArrayElements…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(1,542 Views)
Solution
Accepted by topic author DomLabView

If you really need this, you can make a mallable vi that can accept any type of array. This way you don't have to make a new sub VI for each type of data. See attached for a simple example

0 Kudos
Message 3 of 5
(1,538 Views)

Thanks a lot!
I never stumbled across those malleable vis. What a tremendous new power....

LV 2018
0 Kudos
Message 4 of 5
(1,523 Views)

If you often use arrays in which not all indices are occupied, you can also think about other data structures like Sets/Maps (since LV2019) or the usual variant attributes. Then you can also use strings or other types as an index

0 Kudos
Message 5 of 5
(1,519 Views)