LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get the last index of a string array


@sinclair15 wrote:

how to get the last index of a string array? the array size is always changes in certain situations


https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/index-string-array.html

alexderjuengere_0-1756297123839.png

 

0 Kudos
Message 11 of 16
(191 Views)

Hi Alex,

 

nice suggestion!

 

(I would like to nominate that for Rube-Goldberg because of the slightly larger icon and the required "0" constant when compared to IndexArray... 😄 )

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 12 of 16
(180 Views)

@GerdW wrote:

(I would like to nominate that for Rube-Goldberg because of the slightly larger icon and the required "0" constant when compared to IndexArray... 😄 )


The other difference between "index array" and "index string array" is the optional upper string input that gets prepended to the indexed string. Since it is not wired here, Rube Goldberg would be proud 😄

 

altenbach_0-1756303633195.png

 

(I am not even sure why we would need such a special purpose string function cluttering the palettes... 😄 )

 

Also try to read the context help three times fast 😮 )

 

 

 

0 Kudos
Message 13 of 16
(166 Views)

I didn't expect it to be this busy.
I found it using your method, which is by reducing the array size by one.
Sorry for the late reply, as I haven't been using my laptop much lately. Thank you all🙏

0 Kudos
Message 14 of 16
(97 Views)

@altenbach wrote:

(I am not even sure why we would need such a special purpose string function cluttering the palettes... 😄 )

 

Also try to read the context help three times fast 😮 )

 


I know this node exists forever (started with 5.1) and I never really had to use it. But I suspected it to be there for building string commands for devices, such as AT commands for modems, using this function to select commands or arguments from a Lookup-Table-like stringarray. And it makes it easy to chain arguments.

Nowadays I would use enums and the "Format into String" - node, but if the insertable string gets too long for an Enum, its reasonable to translate a short enum- description to the LUT- element.

My two cents...

Greets, Dave
Message 15 of 16
(79 Views)

@sinclair15 wrote:

I didn't expect it to be this busy.
I found it using your method, which is by reducing the array size by one.
Sorry for the late reply, as I haven't been using my laptop much lately. Thank you all🙏


It is difficult to tell what you are replying to, but if you also want to reduce the array size by one, "delete from array" is OK to use. However, that requirement was never mentioned before. 😄

 

As I said, if an array is constantly changing in size, it can be hard on the memory manager and can cause performance issues. Most often, the code can be rearchitected to use a fixed size pre-allocated array of sufficient size.

 

Once you explain in more detail what you are actually trying to do, we can offer more targeted advice.

Message 16 of 16
(58 Views)