06-13-2013 08:52 AM
We are using a 3rd-party component and need to interface from TestStand using COM. The interface uses a Variant to pass data into various objects. We are unable to successfully pass an integer.
When the expected type contained in the Variant is a string or a double, the call is successful. When the expected type is an integer, the call fails. Passing in a Boolean will succeed, but only for 0 and -1.
How can we assign an integer value to a Variant? We can only find Int64() convert functions.
Perhaps a function which returns an integer type can be used to convert a TestStand number (double) to an integer value, but so far, no luck.
Solved! Go to Solution.
06-14-2013 08:11 AM
Hi Variant,
If you can retrieve it as a string, you can use the Val() function to convert to a number.
06-14-2013 09:34 AM
Our situation requires sending a Variant from TestStand which holds an integer. I am not an expert in the use of Variants (despite my tag name) but examples seem to indicate that the Variant type identifier needs to be set prior to making an assignment. I am assuming that TestStand does this for you based on the type that is being assigned. Since TestStand uses a 64-bit double as the storage for Numbers, I am guessing that the type identifier VT_R8 is being set. Special cases for Boolean and String are handled correctly but I can't seem to find a way to coerce a Variant assignment to specify an integer type when calling into the dll.
Now, if the Variant assignment of a double should be able to be extracted by the dll as an integer (using automatic type conversion provided by the Variant), then my premise may be incorrect and there may be a bug in the dll (no source).
06-14-2013 11:10 AM
There is currently no way to pass a 32-bit integer in a VARIANT using the ActiveX/COM adapter. You can pass a 64-bit integer as you've probably already determined, but teststand does not natively store numbers as 32-bit integers and the ActiveX/COM adapter currently has no way to specify a conversion for a data type of VARIANT, so TestStand just stores the numeric type that it natively uses as a VARIANT.
In order to call this method from TestStand you will need to write a wrapper function that does the necessary parameter conversion and calls the method, and then call the wrapper function from TestStand instead.
-Doug
06-14-2013 11:31 AM
Bummer! I was afraid that was the case.
Thanks Doug
06-14-2013 03:10 PM
Update: The wrapper works just dandy!
Thanks again.