07-30-2007 07:07 AM
07-31-2007 11:47 AM
Hi,
This ActiveX control must be from an extremely old version of our software - it is deprecated now. However, from the name and your description, I think is replaced with a native CVI control - a tank.
I think the problem with your code snippet is that you have selected the type VARIANT, instead of a LONG or DOUBLE. Here is the list of possible data types, found in the CVI help:
Data Types for Variants, Safe Arrays, and Properties
A set of fundamental data types exists that is valid for variants, safe arrays, and properties. You can apply a set of modifiers to these fundamental data types to create more data types. Not all combinations of data types and modifiers are valid in all cases. The function descriptions specify which data types are valid in particular contexts. The following table shows the fundamental data types.
| Defined Constant | Data Type or Meaning |
|---|---|
| CAVT_EMPTY | Variant contains nothing |
| CAVT_NULL | Variant contains NULL value |
| CAVT_SHORT | short |
| CAVT_LONG | long |
| CAVT_INT | int (same as CAVT_LONG) |
| CAVT_FLOAT | float |
| CAVT_DOUBLE | double |
| CAVT_CY | CURRENCY (Windows SDK data type) |
| CAVT_DATE | DATE (Windows SDK data type) |
| CAVT_BSTR | BSTR (Windows SDK data type) |
| CAVT_DISPATCH | LPDISPATCH (ActiveX data type for an ActiveX object interface) |
| CAVT_ERROR | SCODE (Windows SDK data type) |
| CAVT_BOOL | VBOOL, which maps to VARIANT_BOOL (ActiveX data type) |
| CAVT_VARIANT | VARIANT (ActiveX data type) |
| CAVT_UNKNOWN | LPUNKNOWN (ActiveX data type for an unknown interface) |
| CAVT_UCHAR | unsigned char |
| CAVT_CSTRING | char * (null-terminated string) |
| CAVT_OBJHANDLE | CAObjHandle, which maps to void * |
08-07-2007 07:35 PM
08-13-2007 09:18 AM
Hi,
I just wanted to add a couple of pieces of information to the post. First off,
CA stands for CVI automation (of course it used to be referred to as C
automation).
To set the Vessel Value property, you could have done something like:
- CWASControlsLib_SetProperty (tank, NULL,
CWASControlsLib__DCWVesselValue, CAVT_SHORT, 10); //
You could have also done CAVT_LONG, CAVT_DOUBLE (of course with double, you
would need to say 10.0 for the value)
Or if you wanted to use a straight-up variant, you could have said
- CA_VariantSetShort
(&jonathan, 10); // Storing a short integer of 10
into a variant
CWASControlsLib_SetProperty (tank, NULL, CWASControlsLib__DCWVesselValue,
CAVT_VARIANT, jonathan);
It is true that the Variant data type (basically just a universal data type)
can store different data types. A Variant in itself is basically two parts
which consist of the actual data value and a section that describes the type of
data it is storing. Now, those defined constants like CAVT_SHORT.
CAVT_LONG are used to help indicate the type of data that is being stored in
that variant. So for example, the CA_VariantSet1DArray function takes some
native array like an array of longs, double, floats, etc and converts that over
to a safe array to be stored in a variant. You specify the variants data type
by using one of defined constants like CAVT_LONG, CAVT_DATE, etc.
To find some examples that use any of those functions or constants, what I like
to do is do a Ctrl+F on the <CV>\samples\ directory, search for All files
and folders, and the type for example, "CA_VariantSet1DArray" in
the "a word or phrase in the file:" option. This will bring up
all examples that use that word. If you type CA_VariantSet1DArray in, you will find several examples
come up like the 3DGraphContours example located in the <CVI81>\samples\userint\activex
A couple helpful documents include What
Are the Variant, SafeArray, and BSTR Data Types and Why Are They Needed?
KnowledgeBase and the Working
with Variants in Visual Basic tutorial.
Hope that helps,