Properties are attributes of a VI, object, or application. Methods perform actions on a VI, object, or application. Use a Property Node to get or set a property of a specific VI, object, or application. Use an Invoke Node to perform an action, or method, on a specific VI, object, or application.
You can create multiple properties and methods for the same VI, object, or application.
Complete the following steps to create a property or method using a Property Node or Invoke Node, or use one of the alternative ways to create a property or method.
- Determine for which object you want to create a property or method. Obtain a reference to that object in one of the following ways:
- VI—If you want to create a property or method for the current VI, you do not have to obtain a reference. If you want to create a property or method for another VI, add the Open VI Reference function to the block diagram.
Open VI Reference
- Front panel object—Right click the block diagram terminal of the object and select Create»Reference from the shortcut menu to create a reference to the object.
- Application—If you want to create a property or method for the current application instance, you do not have to obtain a reference. If you want to create a property or method for another application instance, add the Open Application Reference function to the block diagram.
Open Application Reference
- Determine whether you want to create a property or a method.
- To create a property, add a Property Node to the block diagram.
- To create a method, add an Invoke Node to the block diagram.
- Wire the reference to the object to the reference input of the node. The node automatically changes to show the class of the object that you wired to it. Different classes of objects have different properties and methods available to them.
||Note If you want to create a property or method for the current application or VI, you do not have to wire data to the reference input of the node because LabVIEW uses the current application or VI by default. However, you must manually select either the Application or VI class by right-clicking the node and selecting Select Class from the shortcut menu.
- To select the specific property or method to use, click the white area of the node and select the property or method from the hierarchical menu that appears.
- (Optional) Property Nodes allow you to get or set multiple properties with the same node. To add more properties to the same Property Node, right-click the white area of the node and select Add Element from the shortcut menu or use the Positioning tool to resize the node.
- (Optional) To change a property from read to write, right-click the property and select Change to Read or Change to Write from the shortcut menu.
- If the Property Node returns a reference or an array of references to an object, use the Close Reference function to close the reference.
||Note If you add a property to a While Loop or For Loop and the property returns a reference to an object, you must close that reference for each iteration of the loop. You can move the property outside the loop and close the reference after all iterations of the loop execute.|
Alternative Ways to Create Properties and Methods
- You can use the Class Browser window to browse for and create properties and methods.
- You can right-click a front panel object or its block diagram terminal, select Create»Property Node or Create»Invoke Node from the shortcut menu, and select a property or method from the list to create a property or method for the object. You do not have to wire a reference to the resulting Property or Invoke Node because the node is implicitly linked to the object. If the object has a label, the property has the same label. You can change the label after you create the node. If you select a method, the associated parameters appear in the node.
- (Windows) To create a .NET property or method, wire a .NET container or a .NET reference to the reference terminal of the node.
- To create an ActiveX property or method, wire an ActiveX container or automation refnum to the reference terminal of the node.