05-03-2022 07:56 PM - edited 05-03-2022 08:15 PM
Here is the problem that I am having. Let's say for Enum I, I select 1 and for Enum II I select 1. If choose 2 for enum I or II while the program is running, it goes to default 0 case. How do I prevent it from going to 0. I want when I input 2, case 2 to execute no matter what enum I am using to input the number. If you use highlight execution, you'll know what I mean. (see attached VI).
Note: Bear with me. I am just the baby in here trying to grow.
Solved! Go to Solution.
05-03-2022 08:11 PM
@GRCK5000 wrote:
Here is the problem that I am having. Let's say for Enum I, I select 1 and for Enum II I select 1. If choose 2 for enum I or II while the program is running, it goes to default 0 case. How do I prevent it from going to 0. I want when I input 2, case 2 to execute no matter what enum I am using to input the number. If you use highlight execution, you'll know what I mean. (see attached VI).
Note: Bear with me. I am just the baby in here trying to grow.
I think the forum didn't like your attachment because it never came through.
05-03-2022 08:18 PM
Thanks BillKo. I fixed it.
05-03-2022 09:10 PM
Do you understand the concept of an Enum (a shortened form of "Enumerated Type")? It is a process that lets you (the user/programmer) choose "Human-friendly" names that can be used in place of "counting numbers".
In your program, you have two Dbl variables called "Enum 1" and "Enum 2". They are not "Enums" as LabVIEW (and C, and Pascal, and other programming languages) consider them.
There is an Enum entry on the Front Panel. I'm sure if you learned about Enums (or paid attention in class, or read the Help files, or taken the LabVIEW Core 1 tutorials) you would understand how to use them.
You define an Enum by giving it a name (say, "Color") and specifying its Values on the Front Panel (for example, you can use the Resistor code "Black", "Brown", "Red", "Orange", "Yellow", "Green", "Blue", "Violet", "Gray", "White". Common things to do with an Enum is to get the "Next" item (try the LabVIEW "Increment" function) or "Previous" item (try the LabVIEW "Decrement" function). An interesting function of Enums is they only take their "defined" values -- the next "Color" after "White" is ... "Black".
I use them any time I have a small number of "choices" to make (as opposed to two choices, for which I usually use a Boolean, choices "True" or "False").
Bob Schor
05-03-2022 09:13 PM
@GRCK5000 wrote:
Here is the problem that I am having. Let's say for Enum I, I select 1 and for Enum II I select 1. If choose 2 for enum I or II while the program is running, it goes to default 0 case.
It is actually using the "Default", which just happens to be the 0 case. The reason is that the OR is a bit-wise OR. To keep it simple, 1 is 0b01. 2 is 0b10 in binary. OR those together and you get 0b11, which is 3. So it is actually trying to call case 3. But since you don't have a case 3, it calls the default case.
05-03-2022 10:35 PM
So my question is if there a way. I can call case 2 when I input 2 in either "enum I" or "enum II"?
05-04-2022 06:07 AM
@GRCK5000 wrote:
So my question is if there a way. I can call case 2 when I input 2 in either "enum I" or "enum II"?
Change your case from "2" to "2, 3". Then the case will be active if the input is 2 or 3.
05-04-2022 09:36 AM
Hi,
the Vi's purpose and functionality It is unclear, as @ crossrulz stated, that you should understand the functionality of (OR) in your VI, as an Example :
Enum I : 1 => (ob0001)
Enum II : 2 = (ob0010)
Result (x.or.y ?) = (ob0001) or (ob0010) = (ob0011) = 3 (decimal)
in your VI you don`t have a case for (3) , LabVIEW choose the default case which is (0).
you need to specify the range of the input, if it is between (0,1,2) max (2).
you could use the @ crossrulz solution by adding (3) to the case of (2) => "2, 3"
otherwise it doesn`t work, an Example if you want to choose 2 if it appear on Enum I or Enum II.
Enum I : 4 => (ob0100)
Enum II : 2 = (ob0010)
Result (x.or.y ?) = (ob0100) or (ob0010) = (ob0110) = 6 (decimal)
there is no case for 6, abVIEW choose the default case which is (0).
Best Regards.
05-04-2022 09:56 AM
Please bear with me. I do not want case (3). I want to limit this to case 0, 1, 2
Here is the scenario:
Imagine you are using my VI. You select for Enum 1 -->1 as shown below:
Then you do the same for Enum II as shown below:
Using highlight execution, press RUN. You'll notice the flow goes from 1 to level 2b, then back to 1 (a cycle).
Now, here is the problem: Let's say while it's running. I change Enum I or Enum II input to 2, it would go to 3 which corresponds to 0 (default case) mainly because I do not have case 3. My goal is to force it to go to 2 when I change Enum I or Enum II input to 2. I do not want this to go to 0 default.
How do I do that?
Note: I do not want to add case 3.
05-04-2022 09:58 AM
Hi crossrulz. I tried my best to re-explain what I want to do. Please can you scroll and let me know if that makes things clear and how do I go about doing what I want to do?