LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how manage without global variables?

I have a case structure and within each case I have a test that give a true or false as result. For the test to be "Passed " all the cases must give a true. How can I collect all my true/false signals from the different cases and put them through a "logic AND" berfore sending my final pass/fail signal to my indicator? All signals must be true to make a Pass.

I have been told that too many global variable is bad programming. But I dont understand how I should do to examine if the different true/false signals to make the fina pass/fail without using alot of global variables.

I attach my example to the post if anyone wants to help.

Thanks!
/Fredrik
Message 1 of 11
(3,666 Views)
Hi Fredrik.

First of all, I'm not sure that what you need are global variables. To make sure, could you post a piece of example code, maybe a miniature of the code attached in the first place, which btw is missing both subVIs and globals?

Globals are used when passing data between VIs. Is this what you are trying to do?

A simple example and some more information would be appreciated.

Regards

Anders M
National Instruments DK
Message 2 of 11
(3,643 Views)
Hi metallifredd,

Because you give only the main VI, I cannot access to the sub-vis.

Why don't you use shift register on the loop instead of any global variable?

I made a slight modification of your code with shift register just for you to see.
But because I cannot access to sub-vis, I'm not sure that's what you need.
Best regards,
G Liagre
0 Kudos
Message 3 of 11
(3,638 Views)
Hi Fredrik,

a sidenote first: as "Meister" saied, if you have just some Cases within one VI Locals are enough - but not fine anyway.

I can't open your example (i'm running 7.0) but i hope to undersatnd your problem: Getting out Pass/Fail of a Case-Structure with some different measurements inside.
Try 1) a for-loop with indexing around your case - you will get a boolian array. Thats easy to AND.
Or 2) a while loop around your case with a shift-register.

1) has the benefit, that you can easily figure out whitch test went wrong.


Happy hunting
Stefan
0 Kudos
Message 4 of 11
(3,636 Views)
ok. Im sorry I confused you all.
Here is a very simple example of how it looks.
Regards
Fredrik
0 Kudos
Message 5 of 11
(3,628 Views)
The use of shift register is the best way, I think
Best regards,
G Liagre
0 Kudos
Message 6 of 11
(3,625 Views)
Here is your example with a shift register used to get a "false" if any test is false.

Message Edité par G Liagre le 05-24-2005 12:56 PM

Best regards,
G Liagre
Message 7 of 11
(3,611 Views)
Ahh thanks alot!
Now I get it.
regards
0 Kudos
Message 8 of 11
(3,577 Views)
Is the number of cases known and small (i.e., are you running four different cases every time)? If so, then I would suggest putting each case in a subvi and then anding the results. Also, in your main program I would get rid of the sequence structure and error in and error out clusters to control the order of execution. You can put error in and error out clusters even if all they do is pass the data through the subvi. There is no need for either local or global variables here.
0 Kudos
Message 9 of 11
(3,568 Views)
Sorry I'm jumping into this a bit late, but can't you simply disable indexing on a loop and then OR or AND the outputs together?
Message 10 of 11
(3,548 Views)