Pablo Bleyer Posted April 13, 2007 Report Share Posted April 13, 2007 Hello. I've always wondered, is there a direct way of retrieving the value of a control given its reference? Always using variant to data (as shown in the attachment) is tedious and cumbersome. Thanks in advance. Best regards. Quote Link to comment
AdamRofer Posted April 13, 2007 Report Share Posted April 13, 2007 QUOTE(Pablo Bleyer @ Apr 12 2007, 02:03 PM) Hello. I've always wondered, is there a direct way of retrieving the value of a control given its reference? Always using variant to data (as shown in the attachment) is tedious and cumbersome. Thanks in advance. Best regards. 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. http://forums.lavag.org/index.php?act=attach&type=post&id=5486''>http://forums.lavag.org/index.php?act=attach&type=post&id=5486'>http://forums.lavag.org/index.php?act=attach&type=post&id=5486 If you don't know how to get a strict reference type, then do this: a) Find the control you want to get the strict reference type from. b) Right click on it and select Create Reference. c) Right click on the new reference and select Create Constant. d) Delete the item created in step b. Quote Link to comment
Pablo Bleyer Posted April 17, 2007 Author Report Share Posted April 17, 2007 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. Quote Link to comment
Rolf Kalbermatter Posted April 17, 2007 Report Share Posted April 17, 2007 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 Quote Link to comment
Aristos Queue Posted April 18, 2007 Report Share Posted April 18, 2007 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. 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 Quote Link to comment
Pablo Bleyer Posted April 18, 2007 Author Report Share Posted April 18, 2007 Thanks for the info, rolfk and Aristos. Now everything is clearer now. I thought controller references weren't strict types, since there are times when LV seems to know more about them. ;-) Best regards. Quote Link to comment
Michael Aivaliotis Posted April 18, 2007 Report Share Posted April 18, 2007 QUOTE(Pablo Bleyer @ Apr 17 2007, 10:05 AM) Thanks for the info, rolfk and Aristos. Now everything is clearer now. I thought controller references weren't strict types, since there are times when LV seems to know more about them. ;-) Best regards. We've just added a [wiki]Control References[/wiki] article on the http://wiki.lavag.org/' target="_blank">LabVIEW Wiki. Quote Link to comment
Pablo Bleyer Posted April 19, 2007 Author Report Share Posted April 19, 2007 QUOTE(Michael_Aivaliotis @ Apr 17 2007, 04:29 PM) We've just added a [wiki]Control References[/wiki] article on the http://wiki.lavag.org/' target="_blank">LabVIEW Wiki. Hmmm... Woot, woot. I think that was the missing link. ;-) Very nice article, indeed. Quote Link to comment
Jim Kring Posted April 19, 2007 Report Share Posted April 19, 2007 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> Quote Link to comment
crelf Posted April 21, 2007 Report Share Posted April 21, 2007 QUOTE(Jim Kring @ Apr 18 2007, 03:25 PM) Did somebody say "woo woo"? What the...?!? Not bad about 35 seconds from the end... Quote Link to comment
Jim Kring Posted April 21, 2007 Report Share Posted April 21, 2007 QUOTE(crelf @ Apr 20 2007, 05:53 AM) What the...?!? Not bad about 35 seconds from the end... That's a mix of Bubb Rubb and Little Sis (some of the San Francisco Bay Area's finest spokespeople) on thier TV debut, where they showed off thier whistle tips. http://forums.lavag.org/index.php?act=attach&type=post&id=5566whoooo whooo! Quote Link to comment
crelf Posted April 21, 2007 Report Share Posted April 21, 2007 QUOTE(Jim Kring @ Apr 21 2007, 02:51 AM) ...thier TV debut... ...and finale? Quote Link to comment
Aitor Solar Posted April 24, 2007 Report Share Posted April 24, 2007 I've always (well, since LV8) have a doubt. Why the strictness seems to be represented sometimes with a star and sometimes with an arrow? http://forums.lavag.org/index.php?act=attach&type=post&id=5608 Surely it's obvious . Saludos, Aitor Quote Link to comment
Ton Plomp Posted April 24, 2007 Report Share Posted April 24, 2007 QUOTE(Aitor Solar @ Apr 23 2007, 04:14 PM) http://forums.lavag.org/index.php?act=attach&type=post&id=5608''>http://forums.lavag.org/index.php?act=attach&type=post&id=5608'>http://forums.lavag.org/index.php?act=attach&type=post&id=5608 The first one is a reference to a control (thus strict) The second (right) one is a reference type (thus general) Ton Quote Link to comment
Aitor Solar Posted April 24, 2007 Report Share Posted April 24, 2007 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.