NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

ArrayElementPrototype is NULL

Hello,

I am developing on .NET/ C# platform.

I am trying to programatically get the elements or fields (their types) within each container of a array of containers. As per documentation using the property object of the array I first call the following:

arrayObject.GetDimensions("", 0, out lowerBounds, out upperBounds, out numElements, out elementType);

the return values for lowerbounds/upperBounds/numElements are correct. Also elementType returns PropValType_Container and this is correct because it is an array of conatiners.

And now to iterate through all the elements in the array container as per documentation, I am supposed to iterate through all the properties of "arrayObject.ArrayElementPrototype". But "arrayObject.ArrayElementPrototype" is NULL.

How do I iterate thorugh all the elements or fields of an array container?

In the example I am using I have an array of containers and each container has a string field. Also what would happen if the container in the first index is different from the container in the 2nd index. TestStand does not seems to complain about it. But what do I do programatically in this situation?

Thanks,
Harsha
0 Kudos
Message 1 of 3
(3,207 Views)
Harsha,
 
The 'ArrayElementPrototype' is a template from which new elements are copied when the size of the array increases.
When you create an array of containers ths property will be initially NULL.
If you create an array of named types the template would contain the subproperties specified by the type.
If you want you can set the ArrayElementPrototype of an array of containers, but if you want all the elements of the array to have the same fields, probably you should create a Custom Data Type and use an array containing elements of your custom data type.
I am not sure you need the 'ArrayElementPrototype' property to iterate through the elements of an array of containers.
Where did you read about this?.
In order to get an specific array element you can use the 'GetPropertyObjectbyOffset' method.
Once you have the array element you ca use the 'GetValString' method in order to access the string field.
Could you provide more details about your use case?
 
Hope it helps.
 
0 Kudos
Message 2 of 3
(3,193 Views)
Antonio,

I realized a little later I am on the wrong track and did exactly what you mentioned. I access the element in the first index, using which I am able to iterate through all the elements in the array container. I am doing all this because I am trying to convert all the "Locals" in a sequence into a XML Schema and the "Locals" may contain an array.

Thanks,
Harsha


0 Kudos
Message 3 of 3
(3,184 Views)