LabVIEW 2018 Help
View Product Info
DOWNLOAD (Windows Only)
Constants are terminals on the block diagram that supply fixed data values to the block diagram. Universal constants are constants with fixed values, such as pi () and infinity (). User-defined constants are constants you define and edit before you run a VI.
Complete the following steps to create a user-defined constant.
- Right-click an input terminal of a VI or function and select Create»Constant from the shortcut menu. LabVIEW creates a constant of the default data type of the input terminal and highlights the value.
- Type the value you want to assign to the constant and press the <Enter> key.
You also can press the up and down arrow keys to assign a value to the constant. LabVIEW resizes the constant to fit its contents. You can resize a string constant the same way you resize a label.
- Use the Operating or Labeling tool to click the constant and edit its value. If automatic tool selection is enabled, double-click the constant to switch to the Labeling tool and edit the value.
|Note LabVIEW uses constant folding to optimize the performance of VIs. You can display constant folding on the block diagram by selecting Tools»Options, selecting Block Diagram from the Category list, and placing a checkmark in the Show constant folding of wires checkbox.|
You also can create a constant in the following ways:
- Search for a constant or select it on the Functions palette and add it to the block diagram. Most constants are located at the bottom or top of their palettes.
- Search the LabVIEW Help for a constant and click the Add to the block diagram button to place the constant on the cursor so you can add it to the block diagram. Click the Find on the palette button to highlight the constant on the Functions palette.
- Drag a front panel control to the block diagram. LabVIEW creates a constant with the value of the front panel control at the time you dragged it to the block diagram. The value of a refnum constant is Not A Refnum. The control remains on the front panel. Changing the value of the front panel control does not affect the constant value on the block diagram and vice versa.