Jump to content

Control value through reference


Recommended Posts

QUOTE(AdamRofer @ Apr 12 2007, 05:18 PM)

If you know the type of the control (such as Digital), you can use To More Specific Class and cast it to that strict type...Value then returns the the value in the type that the strict reference has.

Thanks for the reply but, yes, I already knew that and, again, it's not direct. I guess I was expecting LV to discover the correct value of my reference without casting. It seems since the data is variant that information is effectively lost and value operations can't be bijective (like a pointer to void in C/C++). LV keeps track of the correct type of other properties of references so I was expecting that it also kept track of the correct type of the value.

Regards.

Link to post
Share on other sites

QUOTE(Pablo Bleyer @ Apr 16 2007, 01:56 AM)

Thanks for the reply but, yes, I already knew that and, again, it's not direct. I guess I was expecting LV to discover the correct value of my reference without casting. It seems since the data is variant that information is effectively lost and value operations can't be bijective (like a pointer to void in C/C++). LV keeps track of the correct type of other properties of references so I was expecting that it also kept track of the correct type of the value.

Regards.

The problem is not that the variant does not know what datatype it contains but the fact that LabVIEW is very strictly typed. And that is why there is a difference between a strict typedefed control reference and a non-strict one. These are decisions that are made at compile time and if the datatype of something can possibly change at runtime somehow then the only solution in LabVIEW to still be able to access that datatype at runtime are variants. If you make the refnum strict that is not necessary and if the refnum is non-strict it is necessary, otherwise LabVIEW could in no way allow you to access the Value property at all.

To change that would require to change the entire LabVIEW system to be weak typed but weak-typing has other disadvantages one of them being that a datatype is usually always of some kind of variant type and the necessary (and usually quite time consuming) conversions are always done at runtime. Strict typing has the advantage that most type conversions can be done at compile time resulting in significantly improved performance at runtime.

Other disadvantages of weak typing are the possible loss of information when converting multiple times between different types, or the fact that certain type conversions are simply not useful but you only see that at runtime instead of at compile time.

Rolf Kalbermatter

Link to post
Share on other sites

QUOTE(Pablo Bleyer @ Apr 16 2007, 01:56 AM)

How can we know at compile time what Control Refnum you will be sending down the wire? The Control Refnum could be a reference to any control in LabVIEW, thus we have to be able to give you the data in a type agnostic format -- the variant. When you tell us what type you'd like, we check the variant to see if that type is what is there and give it to you if possible (we also return an error if the types turn out not to match). To say that we ought to have a more specific type on the value wire is a logicial problem -- how can we know the type if you only give us a generic refnum?

Now, what you could do is change the data type of your FPTerminal... instead of using a generic Control Refnum, use a Numeric Control Refnum. If you give us a strict type in the first place, then we'll give you a strict type for the value. Like this:

http://forums.lavag.org/index.php?act=attach&type=post&id=5536''>http://forums.lavag.org/index.php?act=attach&type=post&id=5536'>http://forums.lavag.org/index.php?act=attach&type=post&id=5536

Link to post
Share on other sites

QUOTE(Pablo Bleyer @ Apr 17 2007, 09:25 PM)

Hmmm... Woot, woot. I think that was the missing link. ;-) Very nice article, indeed.

Did somebody say "woo woo"?

<object width="425" height="350"><param name="movie" value="http://www.youtube.com/watch?v=qaXa55ONxvQ"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/watch?v=qaXa55ONxvQ" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

Link to post
Share on other sites

QUOTE(Aitor Solar @ Apr 23 2007, 04:14 PM)

The first one is a reference to a control (thus strict)

The second (right) one is a reference type (thus general)

Ton

Link to post
Share on other sites

QUOTE(tcplomp @ Apr 23 2007, 04:23 PM)

The first one is a reference to a control (thus strict)

The second (right) one is a reference type (thus general)

But the arrow in the Static VI reference lends me to think it's also strict... and it's not. Anyway, it doesn't mind. Thanks, Ton.

Saludos,

Aitor

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.