‎11-20-2012 05:11 PM
I am running into a problem when trying to use variants in my application. I have a state machine set-up in that one state creates a task list (cluster of arrays) and then converts it to variant. The variant is fed into a shift register that allows me to access the task list from a different state.
The problem comes when I try to use the Variant to Data function. I right click on the task cluster to create a constant, and then wire that to the TYPE terminal of the Variant to Data Function. I wire the task cluster variant to the VARIANT terminal. When I run the VI, i get error 91: Possible reason(s): LabVIEW: The data type of the variant is not compatible with the data type wired to the type input.".
How can I get this error when the type I wired to the TYPE terminal of the Variant to Data terminal is a constant created from the exact type created a variant from???
Section of the state machine where I wire the cluster to variant:
Section of the state machine where I use the Variant to Data to get the cluster out:
The constant wired to the Variant to Data TYPE terminal was created from the cluster that is wired to the Data to Variant. I do not understand how there can be a type mismatch???
Solved! Go to Solution.
‎11-20-2012 05:16 PM
Is your cluster a typedef? If not, two clusters that are created that look the same may not be the same. For example, if you create two clusters each containing a string, a number and a boolean but create the elements in a different order the two clsuters appear to be the same but are actually different. I recommend that you use typedefs.
‎11-20-2012 05:18 PM - edited ‎11-20-2012 05:19 PM
Are there any other state that run between these two? I am noticing you have some "Use default if unwired" tunnels comming out of your case structure. First of all, disable that on the tunnels. Secondly, for those cases where you are not affecting that data, wire the data straight from the input tunnel to the output tunnel. I recommend using the linked tunnels to make it even easier on yourself.
With the default tunnels being output, your variant coming in could really be empty, therefore the conversion fails.
‎11-20-2012 05:21 PM
I see you have set the variant tunnel on the right side of the case structure to "Use default if unwired". This can bite you in the... Make sure it is wired across in ALL states, otherwise what is happening is you are calling some state in between that is not wired and the default value for the variant is an empty variant. I HIGHLY recommend right-clicking those terminals and unchecking "Use default if unwired" unless you absolutely need it. It's much better to see errors at design time than at run-time.
‎11-20-2012 05:22 PM
@crossrulz wrote:
Are there any other state that run between these two? I am noticing you have some "Use default if unwired" tunnels comming out of your case structure. First of all, disable that on the tunnels. Secondly, for those cases where you are not affecting that data, wire the data straight from the input tunnel to the output tunnel. I recommend using the linked tunnels to make it even easier on yourself.
With the default tunnels being output, your variant coming in could really be empty, therefore the conversion fails.
Are you stalking me today? Every single post I've clicked comment on, you beat me by a hair!
‎11-20-2012 05:26 PM
@Charles_CLA wrote:
@crossrulz wrote:
Are there any other state that run between these two? I am noticing you have some "Use default if unwired" tunnels comming out of your case structure. First of all, disable that on the tunnels. Secondly, for those cases where you are not affecting that data, wire the data straight from the input tunnel to the output tunnel. I recommend using the linked tunnels to make it even easier on yourself.
With the default tunnels being output, your variant coming in could really be empty, therefore the conversion fails.
Are you stalking me today?
Every single post I've clicked comment on, you beat me by a hair!
No, just 12 hour days (due to the holiday) get really long...and you are just slow.
‎11-21-2012 08:15 AM
Good catch on using the "Use Default if Unwired" on the tunnels of the case structure
I wired data straight from the input to the output tunnel in cases where it is not used. This fixed the issue and everything is running smoothly now.