04-09-2024 02:52 AM
Hi All,
We have been assigning names to the Name property of each element of an array of containers. The containers themselves have just two sub-properties; a string and a bool. We would like in our sequence to pass a string parameter in and and see if it matches the Name property of any elements in the array. We know we can iterate over the array of containers each time we need to do this check, but that feels clunky and that there is likely a more elegant method available.
The reasons we would like to do this is the string property of each item in the array holds a NI CompactDAQ Digital Line string for a line we would like to control and the Name property given to the array elements allow us to provide a more meaningful name.
Any support on this would be much appreciated.
Regards
John
04-09-2024 03:02 AM
Hi John,
I am not aware of an "un-clunky" way to achieve this in TS, yet I would be happy to learn!
Basically, you need something like a dictionary...
04-09-2024 03:57 AM
Hi Oli_Wachno,
Thanks for your quick response. It seems we can achieve our intention within a TestStand statement step using the PropertyObject.Exists method. All we needed to do was properly form the lookup string so it included the brackets and quotes, such as "[\"" + locals.lookupStr + "\"]". Such as: -
Locals.ItemFound = Locals.MyArray.Exists("[\"" + Locals.ItemToFind + "\"]", 0)
This seems to be a more concise method.
John
04-09-2024 04:05 AM
Thanks for sharing this solution!
04-09-2024 04:06 AM
Glad to find and offer it.