Creating a Case Structure to Execute Conditional Code

LabVIEW 2018 Help


Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)


LabVIEW 2015 Help
LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help

Use a Case structure to specify two or more case subdiagrams that execute based on the input value you pass to the structure. Refer to the Case Structure - Selector Data Types VI in the labview\examples\Structures directory for an example of using Case structures.

Complete the following steps to specify values of case subdiagrams when you create a Case structure.

  1. Add a Case structure to the block diagram.

  2. Wire an input value to the case selector to determine which subdiagram executes. You can position the case selector anywhere on the left border of the Case structure. Wire different data types to the case selector to create specific types of subdiagrams, as shown in the following table.
    Data Type Subdiagrams of Case Structure
    Boolean The structure has a True case and a False case.
    Error clusterThe structure has an Error case and a No Error case. You also can use an error cluster to handle errors.
    Integer, string, or enumerated typeThe structure can have any number of cases.
    Note Note  By default, string values you wire to the case selector are case sensitive. To allow case-insensitive matches, wire a string value to the case selector, right-click the border of the Case structure, and select Case Insensitive Match from the shortcut menu.
    Tip  To convert a tunnel to the case selector, right-click the tunnel and select Replace with Case Selector from the shortcut menu. If the previous case selector is wired, LabVIEW converts the previously wired case selector to a tunnel. You can also use the Replace With Case Selector method to convert a tunnel to the case selector programmatically.
  3. Add objects inside the Case structure to create subdiagrams that the Case structure can execute. If necessary, add or duplicate subdiagrams.
  4. For each case, use the Labeling tool to enter a single value or lists and ranges of values in the selector label at the top of the Case structure. The values you enter in each selector label execute a specific subdiagram based on the input value you pass to the structure.
    Note  For values of case subdiagrams with a string data type, use backslash codes to indicate backslashes and non-displayable characters. For example, enter \\ to indicate a single backslash and \r to indicate a carriage return.

WAS THIS ARTICLE HELPFUL?

Not Helpful