LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

local variable as case heading

forgive me for asking such a basic question, but I'm rather new to labview and I can't seem to find the answer:
Is there a way to use a local variable as a case heading?
for instance:
if input value equals (user defined variable) A, then . . .
if input equals (user defined variable) B, then . . .
else . . .

I can make some convoluted wiring diagrams to accomplish this, but I'm having trouble making a nice concise piece of code.
thanks in advance.
0 Kudos
Message 1 of 4
(2,697 Views)

If you want to match one of several values, the easiest way is usually to build them into an array and then search that array. You can wire the result into the case structure and you will get either the index of the match or a -1. You should note that this can also be done without local variables, which is usually better. Generally, locals should only be used as secondary access points to controls and indicators, not as actual variables.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
Message 2 of 4
(2,692 Views)
In answer to your query, yes you can make very capable if then else statements using the case structure.  In the tutorials there are a number of examples of how to set them up for a variety of circumstances (i.e.  1200.. would execute for all values greater than 1200).
 
Good luck.
Jim

LV 2020
Message 3 of 4
(2,687 Views)
thanks. the search 1D array function was exactly what I needed here.

I have looked through many a tutorial at this point, but sometimes you miss things here and there. that was the functionality I was looking for though.
0 Kudos
Message 4 of 4
(2,672 Views)