mike5 Posted March 23, 2010 Report Share Posted March 23, 2010 Is there a way to create a not-a-refnum of a specific type (sort of like NULL pointer)? For example, the shared variable refnum. Is it even necessary? What I would like to do is have a list of shared variables that I have opened, and I would like to know if the refnum is valid or not without some extended logic that tries to read from it or something like that... Miha Quote Link to comment
Rolf Kalbermatter Posted March 23, 2010 Report Share Posted March 23, 2010 Is there a way to create a not-a-refnum of a specific type (sort of like NULL pointer)? For example, the shared variable refnum. Is it even necessary? What I would like to do is have a list of shared variables that I have opened, and I would like to know if the refnum is valid or not without some extended logic that tries to read from it or something like that... Miha For all LabVIEW built in LabVIEW refnums you can simply use the Not A Refnum primitive in the Comparison palette. This will not just check if the refnum is a NULL refnum but actually verify that the refnum refers to an actually still opened object. I'm not sure if your shared variable refnum is a built in refnum or some pseudo refnum but you can easily try that out. This function has the additional advantage that it does not depend on some strange features in newer LabVIEW versions. If you compare certain refnums (VI server refnums) with the (Not)Equal function since LabVIEW 8.0 you do get for instance equality eventhough the refnum is technically not the same, but it does point to the same object (VI refnums work for instance like that). Quote Link to comment
mike5 Posted March 23, 2010 Author Report Share Posted March 23, 2010 For all LabVIEW built in LabVIEW refnums you can simply use the Not A Refnum primitive in the Comparison palette. This will not just check if the refnum is a NULL refnum but actually verify that the refnum refers to an actually still opened object. I'm not sure if your shared variable refnum is a built in refnum or some pseudo refnum but you can easily try that out. This function has the additional advantage that it does not depend on some strange features in newer LabVIEW versions. If you compare certain refnums (VI server refnums) with the (Not)Equal function since LabVIEW 8.0 you do get for instance equality eventhough the refnum is technically not the same, but it does point to the same object (VI refnums work for instance like that). Yes, I was aware of this function, but I am not looking for a way of comparing two refnums (I'll need it of course), but I am looking for a way of instructing "set this variable to not-a-refnum". Miha Quote Link to comment
Stagg54 Posted March 23, 2010 Report Share Posted March 23, 2010 Yes, I was aware of this function, but I am not looking for a way of comparing two refnums (I'll need it of course), but I am looking for a way of instructing "set this variable to not-a-refnum". Miha You could probably just wire it through a case structure. In one case jus pass the refnum. in the other case (ie. when you want to set it to not-a-refnum) just leave the output tunnel unwired and select "use default if unwired" that should do the trick. Quote Link to comment
Ton Plomp Posted March 23, 2010 Report Share Posted March 23, 2010 You could probably just wire it through a case structure. In one case jus pass the refnum. in the other case (ie. when you want to set it to not-a-refnum) just leave the output tunnel unwired and select "use default if unwired" that should do the trick. Or 'create constant' Quote Link to comment
jdunham Posted March 23, 2010 Report Share Posted March 23, 2010 You could probably just wire it through a case structure. In one case jus pass the refnum. in the other case (ie. when you want to set it to not-a-refnum) just leave the output tunnel unwired and select "use default if unwired" If you use a Diagram Disable structure for this, it makes your intent clearer. You can also use 'create constant' but you will want to make sure that it doesn't have some non-null value in the constant when you create it. Quote Link to comment
Aristos Queue Posted March 23, 2010 Report Share Posted March 23, 2010 If you use a Diagram Disable structure for this, it makes your intent clearer. You can also use 'create constant' but you will want to make sure that it doesn't have some non-null value in the constant when you create it. Please don't do this. The fact that LabVIEW allows "Use Default If Unwired" on conditional disable structures continues to cause all sorts of problems, problems of such complexity that various people are pushing to mutate that feature away in future versions. A block diagram constant of a reference type is ALWAYS "not a refnum". Just use that. If you're interested in the kinds of problems, here's just one for a sample: You have a disabled diagram structure with three frames, as shown below: You save the VI and close it. Later, you load this VI back into memory, but this time, someone has edited the subVI to have a different output type. When LV checks the types of terminals of this diagram, this time it decides that the output type needs to be the new type, which causes your diagram to break. That's a problem since the whole point of diag disable is supposed to isolate your code from the possibly broken code inside the structure. Similarly, if the subVI is missing, LabVIEW will use the third case to determine the tunnel's type, and the output would turn to double instead of string. This is one of the easy cases. They get much more bizzare and it is all the fault of "Use Default If Unwired". 1 Quote Link to comment
Rolf Kalbermatter Posted March 24, 2010 Report Share Posted March 24, 2010 Yes, I was aware of this function, but I am not looking for a way of comparing two refnums (I'll need it of course), but I am looking for a way of instructing "set this variable to not-a-refnum". Miha I used to use the Not A Refnum constant for this. Yes is it not of a specific refnum type but that is seldom a problem since it coerces easily into any other LabVIEW refnum. Since about LabVIEW 8 you can also right click on a tunnel or terminal and select Create a Constant and it will actually create an according, typed refnum constant that has the canonical value of Not A Refnum. 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.