07-29-2010 10:48 AM
Hello,
Can you tell me how I can get the Nth variable in a container?
I've tried accessing it using PropertyObject's mehods, but PropertyObject only has methods to get the name of the nth variable (or array).
How can I access the variables I have in a container, programmatically, like the way you get the next element in an array?
Thanks,
Naeemeh
07-29-2010 12:59 PM
07-29-2010 01:09 PM
I'm using ActiveX action to be able to use PropertyObject's methods, and it doesn't
show me this method in the drop down menu. It has GetNthSubPropertyName but not GetNthSubProperty.
The attached picture shows the functions I have available.
Thanks,
Naeimeh
07-30-2010 12:46 AM
Hi
This code snipped shows
How i will iterate through an array of strings.
pObjArray->GetDimensions ("", 0, &bstrLowerBounds, &bstrUpperBounds, &lNumElements, &enType);
if(enType == PropValType_String && lNumElements > 0){
for( LONG i = 0; i < lNumElements; i++){
strLookup.Format("[%i]",i);
strLine = (LPCTSTR)_bstr_t( pObjArray->GetValString(_bstr_t(strLookup), 0));
strLine += "\n";
StdioFile.WriteString(strLine);
}
}
Note: Here i am acessing through the index. This will work for every kind of container
Maybe this helps.
Regards
Juergen
07-30-2010 01:08 AM
Hi
notice you are using TS 3.5, therefore you will need to use
GetNumSubProperties and then index through using GetSubPropertyIndex or possibly GetNthSubPropertyName until you find the property you require.
07-30-2010 08:59 AM
Hi Juergen,
Thanks alot for the code 🙂
So just to make sure, the code you've written is in C and I need to use the C/C++ DLL to add it
to my TestStand sequence, right? I can't just write it in a Statement step in TestStand, right?
Thanks for you help,
Naeemeh
07-30-2010 09:10 AM
And another issue.
I have 16 arrays in my container and I need to get these arrays one by one. I know the dimensions
of the container.
There are methods to get numbers, strings, etc. (like the one you used GetValString()) but the is no function to
get an array, like GetValArray().
What I'm looking for is a way to write something like below:
for(each array in MyContainer)
for(each element in the array)
//Do Something
end
end
Thanks,
Naeemeh
07-30-2010 09:13 AM
Hello,
Thanks for the suggestions but none of those mehods give me the properties.
GetNumSubProperties tells me how many properties there are and GetNthSubPropertiesName gives me their names??
Thanks,
Naeemeh
07-30-2010 10:03 AM - edited 07-30-2010 10:05 AM
For properties use the names you get from GetNthSupropertyName with GetPropertyObject as the lookup string parameter for that method.
For arrays use GetNumElements(), then GetValStringByOffset/GetValNumberByOffset/etc. depending on the type of your array by using the offset as an index from. For example:
int numelements = myarray.GetNumElements();
for(int i = 0; i < numelements; i++)
{
double elementval = myarray.GetValNumberByOffset(i, 0);
}
NOTE: You can also get an entire array at once using GetValVariant(), however that can be very hard to deal with depending on the programming language you are using as it will return a variant that contains a safearray.
Hope this helps,
-Doug
07-30-2010 10:22 AM
GetNthSupropertyName gives me the name of the array that I have in my container.
What I want to do is to get the array itself which is inside my container.