From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Run-time Call Stack X-Control

Code and Documents

Attachment

Summary:

The 'StackTracer' x-control demonstrates the power of LabVIEW Scripting and x-controls.  Drop the x-control on your top level GUI front panel, check then enable button, then when the VI is running, the x-control will show, as a tree structure, the VI's that are running.  BEWARE -- The X-Control actually modifies all sub-vi's to cause them to notify the control when they start and stop.  The modifications are done when 'enable' is checked and the mods are reverted when it is unchecked, so be sure it is disabled before you further modify or save any changes to sub-vi's.  This tool is designed as a developement tool for troubleshooting.  The included example demonstrates using it with an event structure to count the number of times a particular subVI is called.

The x-control datatype is a user event.  Register for changes to this user event to get the name of each sub-vi as it is called.

How it works:

The sub-vi's are automatically modified by wrapping all code on their block diagrams in a stacked sequence structure.  A frame is added before the code with a function call that notifies the x-contol that the subVI is running.  A frame is added at the end that notifies the x-control that the sub-VI is complete.  The sequence structure is sized to be slightly bigger than the viewable area and the frame containing the original code is shown, making the modifications "invisible".

Steps to execute code:

  1. Put it on your top level GUI.
  2. Check 'Enable'
  3. Run it.

Screenshots:

stacktracer.png

Development Ideas:

I'm currently working on a stand-alone version that, instead of an x-control to drop on the top level GUI, it will run in a separate window and display the call stack for any VI's running in an open labview project.  Also a simple enhancement would be to allow clicking on the VI names on the tree control to open the sub-vi.

VI attached below

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors