LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search 1D Array ... Changed in 2020 SP1

So I just upgraded to LV2020 SP1 and I'm writing some code.  I went to use the trusted "Search 1D Array" native function and see that it is GONE!

 

It has been replaced by "Search Sorted 1D Array" and "Search Unsorted 1D Array".

 

But here's the catch.  I want to search a 1D array of strings.  And it doesn't appear that I can wire that into either of them.

 

Another oddity:  I could certainly sort my 1D array of strings before searching it (if NI forces me).  But even that doesn't help.  Still can't wire it.

 

See below:

 

 

http://www.medicollector.com
0 Kudos
Message 1 of 33
(832 Views)

Once you wire a string into the 'element' input of the Search Unsorted 1D Array.vim, the string array wire will no longer be broken.

DNatt, NI
0 Kudos
Message 2 of 33
(810 Views)

Ahhh... so easy ... and yet so confusing.

 

I think this is poorly implemented in the IDE.  If I wire a string to the element node, it shows a broken arrow:

Capture.JPG

But if you wire strings to BOTH nodes, then the broken array to go away

Capture3.JPG

Seems poorly implemented to me.  I would assume that when you wire a string to the element node, the IDE should change the array node to an expected array of strings. 

http://www.medicollector.com
Message 3 of 33
(801 Views)

I agree completely.

DNatt, NI
0 Kudos
Message 4 of 33
(798 Views)

@josborne wrote:

Ahhh... so easy ... and yet so confusing.

 

I think this is poorly implemented in the IDE.  If I wire a string to the element node, it shows a broken arrow:

Capture.JPG

But if you wire strings to BOTH nodes, then the broken array to go away

Capture3.JPG

Seems poorly implemented to me.  I would assume that when you wire a string to the element node, the IDE should change the array node to an expected array of strings. 


It would be too logical to think that it should behave similarly to the polymorphic VI that it is supposed to be an alternative to.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 33
(796 Views)

I made an updated Array palette file for LabVIEW 2020 SP1 that includes the Search 1D Array function. It's attached here (inside a zip file, since apparently the forums don't let me attach a .mnu file). Only use this file with LabVIEW 2020 SP1, and make sure to back up the original first. Here is the specific file you want to replace:

 

LabVIEW 2020\menus\Categories\Programming\array.mnu

 

After replacing the file, you can refresh the palettes by either restarting LabVIEW or dropping the 'Refresh Palettes' method in a VI and running it. Let me know if this works for you.

 

 

DNatt, NI
Message 6 of 33
(771 Views)

Dunno if this is in the online help, but I don't have 2020 SP1 to check.

 

Is it fair to assume that the "Search Sorted 1D Array" will use a binary search, or some other algorithm whose speed scales better than a linear search?  If the item being searched for occupies 4 consecutive indices in the sorted array, which index is returned?  Or will it depend on where those indices are relative to the bin boundaries of the binary search?

 

 

-Kevin P

0 Kudos
Message 7 of 33
(729 Views)

@Kevin_Price wrote:

If the item being searched for occupies 4 consecutive indices in the sorted array, which index is returned?  Or will it depend on where those indices are relative to the bin boundaries of the binary search?


I just tried it. Depending on the size of the array and where the duplicates lie within that range, you'll get different indices returned. I suspect this is how most binary searches work.

DNatt, NI
Message 8 of 33
(702 Views)

Here's a VI (attached) that will add Search 1D Array back to the Programming >>> Array palette programmatically.

 

Add to Palettes - Search 1D Array.png

 

It creates a backup of the original and it only adds it to the palette, if it's not already there. So, it should be pretty safe to run on even if someone accidentally runs it on something other than LabVIEW 2020 SP1.

 

Please take a look at the code to see if there's anything you recommend changing.

 

If this is helpful, I'll probably end up creating a VI Package for this and publishing it on VIPM.io.

JKI Blog
Message 9 of 33
(557 Views)

@Jim_Kring wrote:

 

Please take a look at the code to see if there's anything you recommend changing.


Your VI looks fine to me. I assume if you build this into a VIPM package you'll have a post-uninstall VI that restores the backup .mnu file?

DNatt, NI
0 Kudos
Message 10 of 33
(469 Views)