From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to test if (EVENT) CTRLREF Exists?

Hey everyone,
 
In an event structure if inside an event such as mouse down, I pull out the ctrlref, is there a way to test that it is actually a reference to a control.  For example take  a look at the pictures included.  The problem is that I use this ctrl reference in a seperate event and if i click somewhere on the front panel and there's not a control there, it crashes because then it tries to do stuff to a nonexistance control reference.
 
Thanks for the help, this is the best forum I've ever been in
 
 
 
Download All
0 Kudos
Message 1 of 5
(2,818 Views)
Absolutely! Look in the Comparison palette for a function called Not a Number/Path/Refnum. It outputs True or False. Hope this helps!
Jarrod S.
National Instruments
Message 2 of 5
(2,811 Views)

As asked, I'm here as well, to add to Jarrod's answer.

He told you how to check if a reference is valid, and I'm here to say that I have no idea why your VI is crashing.
You're registering for a mouse down on a list of existing controls. Therefore, the event should fire only if you click the mouse while it's over one of those controls and you should have no reason to check for an invalid control. Even if you would have registered for a non existing control, the event structure should simply not have fired. If LV's crashing, then something is wrong. I ran your VI and it did not crash. Did you do any changes to it?


___________________
Try to take over the world!
0 Kudos
Message 3 of 5
(2,798 Views)
I believe IEC is taking those control refnums (refna? 😉 ) and wiring them to a shift register to store them for later use. At times IEC also explicitly wires null references to those shift registers, so it's always uncertain what's currently stored in them.

You are correct that the event case itself should never output a null refnum from the event data node, but I don't think that's what's happening here.

Message Edited by Jarrod S. on 08-17-2006 02:48 PM

Jarrod S.
National Instruments
0 Kudos
Message 4 of 5
(2,793 Views)

You're right. I was looking at an older version of the code.

In any case, the program shouldn't crash, but the property node should throw an error. Since you don't have the error out terminal wired, and it's likely you have automatic error handling enabled, LV will immediately display a dialog with the error info (which I assume is the problem you refered to). You can get rid of this dialog either by disabling auto error handling or by wiring the error out terminal into something. In general, it is very important to handle errors properly, but that is a very big discussion and we can't go into it.


___________________
Try to take over the world!
Message 5 of 5
(2,783 Views)