To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example uses Dynamic Event Registration to facilitate communication between a top-level VI and its subVIs.
Description
This example shows how to not only pass UI messages down to a subVI, but also pass them back to the main application. By using the Event Dynamic Registration terminal I can register user events. Inside the subVI, I have another event structure that generates another user event that is processed by the main application.
Requirements
Steps to Implement or Execute Code
The subVI is set to open when called, and set to close after 20 iterations. Any button pressed while the subVI is running will be captured and be processed once the current action is complete. For instance, run the main application and press the Queue Event switch, this will launch the subVI. Now pull the Queue Event Switch while the subVI is running. Once the first 20 iterations are complete, then the subVI will launch again and run for another 20 iterations.
Additional Information or References
Block Diagram of Main.vi
Block Diagram of Sub.vi
Note by contributor: This is a useful example, but the supplied code is poorly documented. Attached is my shot at a well-documented (LabVIEW 2009) version of the same example.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Great code, very usful tutorial!
Good, It's easy to understand.