LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Case Structure

Hi,
 
I have an application where i created a case structure within the For loop.Main idea is i have to create the array of cluster.
case structure format is like this
switch(Numeric value)
{
case "1":
            It has to take the data from the controls in the front panel and put those values in the cluster
            break;
case "2":
          It has to take the data from the controls in the front panel and put those values in the cluster
          break;
case "negative value":
           Do nothing
          break
}
i have kept the cluster inside the for loop but outside the case structure and array outside the for loop
The problem is, when the case is negative value, I don't want it to do anything. But, the case output needs to be wired for all cases. Is there a way around this using a different method?
 
Help me in this
 
Regards
Meenatchi
 
0 Kudos
Message 1 of 8
(2,998 Views)
Hi Meenatchi,

use a shift register in your for loop to keep the array of clusters. You wire the array through your case structure and add new elements only when needed (case 1 or 2)...

Hint: you can put several case statements in one case like "1,2" when you want to add the same control values.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(2,991 Views)


 


@Meenatchi wrote:
 
The problem is, when the case is negative value, I don't want it to do anything. But, the case output needs to be wired for all cases. Is there a way around this using a different method?

You can use the option "Use Default if Unwired" for the cases for which you dont want to do anything.

But beware that they will output the default FP control values for those cases.

If you want to keep the last updated value to stay, wire a shift register to the For loop thro' all the cases.

See the attached VI & pic for more...

What version of LV re you using ?

I think prior to 6.1, you wont ve the "Use Default if Unwired" option at all; you ve to compulsorily wire for all the cases...

- Partha ( CLD until Oct 2024 🙂 )
Download All
Message 3 of 8
(2,988 Views)
Hi,
 
Thanks for ur reply.
I have seen ur example program.But in that example, i dont want to store any information(not even a default value)into the array if -1 comes.
Is there any way to do that??
 
Ultimate aim in my application is
if(condition)
{
        update into the array
}
else
{
         Do nothing
}
 
Please help in this
 
Regards
Meenatchi
0 Kudos
Message 4 of 8
(2,959 Views)
If your condition is just If/Else, the see the attached VI...
- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 5 of 8
(2,947 Views)
Hi Meenatchi,

you should do it like described before. See attachment!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(2,944 Views)

Hi Meenatchi,

I just scribbled the code to change a little.

Maybe your application can be large.

So, what you ve to do is check all the conditions for updation [ compound OR or compound AND ], and then do it inside the True case.

Else, DO NOTHING inside the False case... thats it...

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 7 of 8
(2,932 Views)

First of all, you problem is incomplete, because you don't define what should happen if the numeric is zero or >2. You need to define all possible conditions.

Attached is a simple version that updates a cluster with new values if a numeric in it is 1 or 2. See if it makes sense to you. (LabVIEW 8.0)

 

 

Message Edited by altenbach on 09-12-2007 09:12 AM

Download All
0 Kudos
Message 8 of 8
(2,909 Views)