Example Code

Pick case based on 3 Booleans

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview:
Detects Boolean logic easier.

Description:
This code makes usage of case structures and the select VI to convert the boolean logic to numbers and depending on the addition result, the correct behavior is displayed.

Requirements:
LabVIEW 2012 (or compatible).

Steps to Implement or Execute Code:
1. Run the VI
2. Activate and deactivate the boolean controls and check on the String indicator that the data displayed matches your selection.

Additional Information or References:
Boolean Options Changes - LV 2012 NI Verified.png
"**This document has been updated to meet the current required format for the NI Code Exchange.**".

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com

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

Comments
leamon
Member
Member
on

i press boolean1,when i want to switch boolen2,i need press boolean1 again ,it is not convenient

if i press boolean1 and 2,there is no string output.

Mark_Holm
Member
Member
on

If all you want to do is check which of three butons is pushed, an event structure would be a lot cleaner.

If you put logic like this inside an event for a fourth button, you could check the positions of three booleans at once, but as shown, it can only reliably check for one at a time (assuming they are front panel buttons).

It would be more elegant and more extensible to make the values increase in binary fashion: instead of 1,10,50 make it 1,2,4...using U32 representation, you could do up to 32 booleans at once this way and any combinations that mattered too.  For instance, assuming you have a setup where you can register more than one boolean at a time, 5 would be the case where inputs 1 and 4 were both true.