You can use VI scripting to programmatically create a new VI and open the front panel and block diagram windows of that new VI.

Note
  • This tutorial assumes familiarity with the VI Scripting introduction.
  • You must enable VI Scripting to display the VI Scripting VI and functions and use the associated properties and methods.

In this tutorial, you will create the following block diagram to accomplish this objective:

Figure 20. Block Diagram: Create and Open a VI with VI Scripting
Block diagram showing wiring between New VI, a Property Node, and Close Reference functions.

To create a VI that uses VI Scripting to create and open a target VI, complete the folowing steps.

  1. Select File » New VI to create a new VI.
  2. Add the New VI function to the block diagram.
  3. Add a Property Node to the right of the New VI function.
  4. Wire the vi refnum output of the New VI function to the reference input of the Property Node.
  5. Resize the Property Node so that it contains three terminals.
  6. Add the following properties to the Property Node:
    • Block Diagram Window:Open: Click the first terminal of the Property Node and select Block Diagram Window » Open. Because the Block Diagram Window properties belong to the VI Scripting class, the Property Node turns blue when you add the Block Diagram Window properties.
    • Block Diagram Window:Window Bounds: Click the second terminal of the Property Node and select Block Diagram Window » Window Bounds.
    • Front Panel Window:Window Bounds: Click the third terminal of the Property Node and select Front Panel Window » Window Bounds.
  7. Right-click the Property Node and select Change All To Write.
  8. Create constants for each property and configure the constants to match the block diagram in Figure 20. Block Diagram: Create and Open a VI with VI Scripting.
    To create a constant for a property, right-click the property and select Create » Constant.
  9. Add the Close Reference function to the right of the Property Node.
  10. Complete all wiring to match Figure 20. Block Diagram: Create and Open a VI with VI Scripting.
  11. Save the VI as ScriptingTutorial.vi.
    For more information, refer to Saving Individual VI Files.
    Tip You can also programmatically save the VI that you create with this tutorial. Use an Invoke Node with the Save:Instrument method. Wire the Invoke Node between the Property Node and Close Reference in Figure 20. Block Diagram: Create and Open a VI with VI Scripting.
  12. Run the VI.
    For more information, refer to Running VIs.

LabVIEW creates and opens untitled front panel and block diagram windows.

To continue this tutorial, continue to the Tutorial: Adding an Object to a VI Using VI Scripting topic.