LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to apply same change to all remaining cases of a case structure?

Solved!
Go to solution

Hello everybody. I would like to consider the following scenario.

 

I have a Case Structure and I have already defined e.g. 100 cases. Now I want to add another object, e.g. a Control Object. How can I avoid to copy-paste this in all cases and just perform this kind of change in one case and make such a change valid for all remaining cases?

 

Thanks in advance for your help 🙂

0 Kudos
Message 1 of 9
(1,630 Views)

Perhaps if you could post your code it would be more clear what you are asking.

0 Kudos
Message 2 of 9
(1,616 Views)

Are you saying you want to add the same object to all 100 cases of your case structure?

 

Why not just put one instance of that object outside your case and wire it into the cases that need it?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 9
(1,586 Views)

If you have 100 cases, the architecture is already questionable. What's is inside the cases? How much is duplicate code?

 

I am not familiar with the terms. If a "control object" is a "control terminal", it definitely belongs before the case structure so any case that needs its value can tap into it.

 

Are you possibly trying to create 100 local variables of the same control? Don't!!! 

 

We really need to see some code. I am sure there is a much better (and scalable!) way for whatever you are trying to do.

Message 4 of 9
(1,577 Views)

Thanks for your reply,  

 

In this situation it's not easy to share the code because it's hosted in a different machine with special rights restriction, so I will try to explain it better here.

 

First in general: I just want to create the same object  in a Case Structure for all cases without manually copy and paste it over and over again. Alternative formulation: I want the same change to be applied inside all cases without manually repeating it for each of them. Is something like that genearlly possible?

 

Going more into details, it's about an experiment involving many valves. Each valve can be read, written and the corresponding writing/reading errors must be shown. In this way, for each valve 4 further objects are needed to the user and all should be available at the same time.

 

Since the reading/writing process has always the same structure/blocks (just with different inputs and setpoints), I thought I could put everything in a while loop, iterating over each case i.e. setting such inputs and setpoints for the specific case. In this way I also occupy less space in the code.

 

Now the trouble is simply that if I want to add a new button or if I want to modify the same object for each valve, it's a bit discouraging to do it manually for each of them. That's the background behind my question. Any useful suggestion is welcome.. 🙂

0 Kudos
Message 5 of 9
(1,549 Views)

Thanks .

I can't do it because this object need to be literally repeated in the front panel. For example, if it's a button, I need 100 buttons in the front panel, not just 1 doing 100 different things. 

0 Kudos
Message 6 of 9
(1,544 Views)
Solution
Accepted by Gpp094

I still think you are approaching this completely wrong. A case structure is typically to select alternative code paths. You seem to use it for identical code paths but different controls. If there is identical code inside each case, that code belong either outside the case or inside a subVI (editing the subVI will globally change the code). Can't you use an array of 100 booleans (e.g. a 10x10 boolean array) and no case structure at all. What is wired to the case selector?

 

If you have an existing case, you can duplicate it to create an identical one. 

 

I am 100% sure there is a better way!

 

 

 

Message 7 of 9
(1,528 Views)

@Gpp094 wrote:

Thanks .

I can't do it because this object need to be literally repeated in the front panel. For example, if it's a button, I need 100 buttons in the front panel, not just 1 doing 100 different things. 


Really? 100 buttons on the front panel? There's got to be a better way. It would be way too easy to get lost in a program where there's 100 of everything. On top of that it sounds like you're using the case structure to select which controls and indicators to use (those aren't objects, they're controls and indicators - objects have a very specific meaning and are only related to object-oriented programming) to run duplicate code. You really need to evaluate your approach to the program.

0 Kudos
Message 8 of 9
(1,521 Views)

@Gpp094 wrote:

Thanks .

I can't do it because this object need to be literally repeated in the front panel. For example, if it's a button, I need 100 buttons in the front panel, not just 1 doing 100 different things. 


100 buttons! That is just wrong on so many levels...

 

You really need to rethink your approach and show us some code. 

 

Frankly just the thought of a case structure containing a hundred or more cases makes my head hurt...

 

If you can't post the actual code (I get it proprietary information and all) then break it down to just this case structure, what is needed to run it, and include a good description of what you are trying to do.

 

Then we all can probably help you figure out a better way.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 9
(1,511 Views)