LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why can't I write Variant back into a cluster control?

I have three clusters with about 21 controls of various types in each.  I would like to store the values of various configurations and be able to swap them out programatically.  I thought I could be clever and just write them out to a binary file and then read them back in, but I keep getting error 91 "The data type of the variant is not compatible with the data type wired to the type input."   I get the error even when I only have one cluster.

How did the datatype become incompatible?




Message Edited by jasonhill on 05-15-2006 04:27 PM

0 Kudos
Message 1 of 9
(3,715 Views)
I'm probably missing something, but I don't understand why, in your write vi, you initialize a variant cluster array with 3 empty clusters then, in the loop, append the read values at the end of the array, leaving the 3 empty clusters as first 3 elements.
Chilly Charly    (aka CC)
Message 2 of 9
(3,697 Views)
DOH!Robot surprised

Yeah.  That would be the problem.  Then the empty variant does not fit back into the cluster.   I was so worried about how to treat the variants and which refnum was which that I completely ignored how I was storing the varaints. Thanks, tst.Robot Happy
0 Kudos
Message 3 of 9
(3,685 Views)

????

"Thanks, tst"

????

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 9
(3,682 Views)
I should just not bother logging in until i have had my first cup of coffee.  Robot Sad

Sorry, CC.  I will shower you with stars in compensation.
Message 5 of 9
(3,678 Views)
Waiting with the soap in hand...
Chilly Charly    (aka CC)
Message 6 of 9
(3,664 Views)

One other thing: You should close the Controls[ ] refnums. LabVIEW may not (probably doesn't) close them automatically when you close the VI refnum. If not, you'll have the functional equivalent of a memory leak. This kind of thing has happened to me in the past. It's good policy always to close dynamically generated refnums, such as Controls[ ], or Pages[ ] of a tab control, etc.

::Marty

Message 7 of 9
(3,637 Views)
Ah.  Good idea.  Not strictly necessary for the current version of LabView (see exhaustive discussion here).  But who knows what future versions might hold.
0 Kudos
Message 8 of 9
(3,626 Views)

jasonhill: Ah.  Good idea [to close dynamically allocated refnums ASAP].  Not strictly necessary for the current version of LabView (see exhaustive discussion here).  But who knows what future versions might hold.

Yes, I would rather close ASAP than rely on LabVIEW's garbage collection or auto-deallocation or whatever you want to call it. There may be situations where a few kbytes matters for a little while. I agree with the posters in the cited thread who say it's good style to close a reference that's no longer needed. Maybe that's overkill, but it's a small price to pay for piece of mind.

::Marty

0 Kudos
Message 9 of 9
(3,615 Views)