LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Type mismatch every other time when in loop

strange behavior. I have a activeX control I wrote and have written a lv wrapper to call the method. I can execute this vi repeatedly with correct results. However, if I use this vi as a sub-vi and place it in a loop, I get a type mismatch error every other time through the loop. Any ideas? Any help would be greatly appreciated.

thanks, in advance
0 Kudos
Message 1 of 2
(2,676 Views)
Dingo,
In LabVIEW 6.0 and later, you can pass a control reference to a subVI and specify the properties of those controls by reference. However, when trying to pass a reference to an enumerated type, any control or indicator in the subVI that uses properties associated with that reference must have the same enumerations as the original enumerated type control or a type mismatch error occurs.

This occurs because the enumerations are part of the definition of that type. Therefore, you must completely define the enumerated type control or indicator in the subVI that uses a value obtained from a reference to another enumerated type. You can do so by...
1) strictly typing the reference with the control after defining each enumeration, or...
2) converting a
variant with a definition that completely specifies all the enumerations.

This example shows the following four ways to avoid the problem. Each method is illustrated in the subVI called 'refnum examples.vi'.

1. Convert the variant type passed by the Property Node to an enumerated type with the same definition as the control you are referencing. You can copy the control and convert it to a constant before wiring it to Variant to Data, or create a constant enum and add the enumerations.
2. Strictly type the refnum in your subVI by dropping a copy of your enumerated type control onto the reference control. A small orange star appears on the control indicating that it is strictly typed.
3. Use a ring control instead of an enumerated type. The data type of a ring control is U16 so it is already fully defined. Because the refnum is not strictly typed, the variant output of the Property Node is converted with a U16 constant.
4. Same as the previous method, but using a strictly typed
refnum. This eliminates the need for the Variant to Data conversion after the Property Node.
Zvezdana S.
National Instruments
0 Kudos
Message 2 of 2
(2,676 Views)