From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

add element to empty array of container

Solved!
Go to solution

Hi, 

I tried  follow this post to add element to empty array of container but cannot.

What i did is create a local container, which contain a string and a number.

In each loop, first fill up the container, then add the container to array of container.

but teststand says ' Variable or property types do not match or are not compatible.'

How to realize it?

thanks.

Nemo

 

 

0 Kudos
Message 1 of 8
(6,249 Views)

You run into a naming convention issue.

Because you name your data structure "Container", you obviously do expect TS to have knowledge of your data structure when you define an array of Container.

Container is a pre-defined data structure in TS and represents an arbitrary collection option for other data. Your array of Container is an array for exactly these not-yet-defined data structures.

 

You solve that static error by defining your Container as a custom data type. Please make sure to use an unique name for it.

The create an array of that new data type and make sure that your Local.MyContainer is also of that new data type.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 8
(6,235 Views)

Thanks.

yes I have to change the name to myContainer.

But I still don't know how to define array of container to the type of mine.

Could you share me some example?

 

0 Kudos
Message 3 of 8
(6,227 Views)

try this

 

locals.arrContainer[locals.iterationCounter].InsertSubProperty("",0,0,Locals.Container.Clone("",0))

 

 

regards

Ray

 

Message 4 of 8
(6,223 Views)
Solution
Accepted by topic author NemoChen

@NemoChen wrote:

Thanks.

yes I have to change the name to myContainer.

But I still don't know how to define array of container to the type of mine.

Could you share me some example?

 


Renaming doesn't help in the type conflict. The only way to get rid of the conflict (besides cloning containers into the array as Raymond suggest) is to create a custom data type and configure both (locals.container and locals.arrcontainer) to derive from the same custom data type.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 8
(6,217 Views)
Solution
Accepted by topic author NemoChen

NemoChen,

 

I think what Norbert_B is saying:

 

create a custom data type MyContainerType

create a local Locals.MyContainer using MyContainerType
create a local empty array Locals.arrMyContainer of MyContainerType

InsertElements(Locals.arrMyContainer,"[" + Str(Locals.iterationCounter) + "]", 1)


locals.arrMyContainer[locals.iterationCounter]= Locals.MyContainer

 

see modified example

 

Ray

0 Kudos
Message 6 of 8
(6,209 Views)

This exactly solved my problem.

Thank you Ray and Norbert_B!

0 Kudos
Message 7 of 8
(6,183 Views)
What are the steps to create custom data type?
0 Kudos
Message 8 of 8
(3,586 Views)