Labview user manual

Page 157

Chapter 9

Event-Driven Programming

Modifying Registration Dynamically If you register for events dynamically, you can modify the registration information at run time to change which objects LabVIEW generates events for. Wire the top left event registration refnum input of a Register For Events node if you want to modify the existing registration associated with the refnum you wire rather than create a new registration. When you wire the event registration refnum input, the node automatically resizes to show the same events on the same types of references as you specified in the Register For Events node that originally created the event registration refnum. You cannot manually resize or reconfigure the function while the event registration refnum input is wired. If you wire an object reference to an event source input of a Register For Events node and you also have wired the event registration refnum input, the node replaces whatever reference was previously registered through the corresponding event source input of the original Register For Events node. You can wire the Not a Refnum constant to an event source input to unregister for an individual event. If you do not wire an event source input, LabVIEW does not change the registration for that event. Use the Unregister For Events function if you want to unregister for all events associated with an event registration refnum. The example in Figure 9-2 shows how you can dynamically change at run time which objects LabVIEW generates events for. When the following block diagram executes, LabVIEW registers the Numeric reference and waits for an event to occur on the associated Numeric control. When LabVIEW generates a Value Change event for the Numeric control, the Numeric Value Change event case executes a Register For Events node to change the numeric control registered for the Value Change event from Numeric to Numeric 2. If the user subsequently changes the value of the Numeric control, LabVIEW does not generate a Value Change event. However, changes to the Numeric 2 control generate Value Change events. Each time LabVIEW generates a Value Change event for the Numeric 2 control, the Register For Events node executes but has no effect because the Numeric 2 control is already registered for the Value Change event.

Š National Instruments Corporation

9-11

LabVIEW User Manual


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.