10-17-2008 04:35 AM
Hi,
I need to initialize many indicators in some of my programs while it is running with the same value. In order to save some space and make my program easier to read, I would like to put all my indicators in a stacked sequence (each step of the sequence has one indicator). As I was saying before, I don't care about the order this is just to make it cleaner. Is this a good solution? I suppose this doesn't change anything to the time it takes in total? (whatever you do : in parallele or sequence)
Thanks
marc
10-17-2008 04:55 AM
Saving space is a good goal, but Stacked Sequence Structures work against your aim to make the program easier to read (your code is hidden). You'd be better off putting all of the indicators (or their local variables) neatly into a flat sequence. You can also make a cluster of references to them and pass that to a sub-VI where you can do whatever initialization is required.
jm
10-17-2008 05:06 AM
Thanks JM,
The problem with a flat sequence is that it takes a lot of space...concerning the "timing", there is no difference, is there?
10-17-2008 05:24 AM
I'd guess that they'd perform similarly, but I don't know.
Here's what I meant about clustering indicator references. I should have said to use an array; I'd only use a cluster if I needed to handle different data types in the same function. This will save space and still be easy to read and easier maintain than a Stacked Sequence.
jm
10-17-2008 07:20 AM
Don't use the sequence structure at all.
Let your code depend on data flow and use state machines. (Init: initialise controls, Main: Handle every thing, Close: Cleanup)
The idea proposed by jcarmodyis the way to go, or you could to make it even more compact get a list of control references from the FP.pane and loop them. You migth have to check the control type before setting the value.
10-17-2008 07:46 AM
BAD MOVE!!!
DO NOT USED STACKED SEQUENCES!!!!! I REPEAT : DO NOT USE STACKED SEQUENCES!!!!
(Caps intentional.. Yes... Yelling that you should NOT EVER USE STACKED SEQUENCES!!!! )
First of all, why do you "need" to initialize your indicators? What you can do, is set default values to them, save your program.. AT the beginning of your program, simply use an Invoke Node with the method: Initialize all to default. It also takes care of the default values of your controls.
Do NOT try to program LabVIEW as if it was a text-based language. You do not need to use Local Variables, either. The variable is the wire in Labview.
I too often see the type of programming that you are suggesting. I'm one of those guys that gets called in to fix code written in such a way. 😞
What you are proposing is not scalable and will not be maintainable in the future. The code will grow... and the proper way to code should be adopted from the start..
R
10-17-2008 07:59 AM
I'm sorry, but I don't think that shouting helps a lot.
And for the
I'm one of those guys that gets called in to fix code written in such a way. 😞
What you are proposing is not scalable and will not be maintainable in the future. The code will grow... and the proper way to code should be adopted from the start..
R
Maybe some pointers to tutorials would help more.
http://zone.ni.com/devzone/cda/tut/p/id/7466
10-17-2008 08:15 AM
andre.buurman@carya wrote:I'm sorry, but I don't think that shouting helps a lot.
And for the
I'm one of those guys that gets called in to fix code written in such a way. 😞
What you are proposing is not scalable and will not be maintainable in the future. The code will grow... and the proper way to code should be adopted from the start..
R
Maybe some pointers to tutorials would help more.
http://zone.ni.com/devzone/cda/tut/p/id/7466
Time for a Sea-story!
Years ago when I was the only person in our branch office (Diebold, when Cash Machines were new and Locksmithing was their bread and butter) who knew anything about comupters I let slip a comment to my boss about "job security". he said;
"Ben, you will find that with time you will go through a series of stages where your part in the company will change as you grow. Typically a person will start a new job and not know tohe first thing about what to do. Over time you will learn your job and have to call on others less and less. Then you will get to the point where you need to ask others very little but will in turn be able to help others. If you keep at it, you will eventually get to the point where things just will not happen unless you are there to advise or help. many people stop growing at that point thinking they have job security. If yo ureally want to grow to your full potential you have to take the next step, train those around you such that you are no longer required to get the job done. At that you are now free to move up thte next challenge."
Ross Beetle circa 1979
I took away from that lecture that I should strive to do my job so well that I never have to do it again. I hear Ray trying to do exactly that. Teach someone so well that they don't need us any more.
Done with my sea story for now!
Ben
10-17-2008 08:21 AM
"I need to initialize many indicators in some of my programs while it is running with the same value" - I read this comment to mean that this was to occur often when the program is running, otherwise I'd have suggested using an Invoke Node. Yours is a better solution if this only needs to happen once and the default values are constant.
As for not initializing FP controls/indicators using a local variable, the LabVIEW Intermediate 1 book recommends doing this; it even shows it being done inside a Flat Sequence structure. I'd prefer to use wires everywhere but sometimes it gets akward and I resort to using locals. I'd agree with your sentiment if you were referring to global variables; I'd even consider typing it in all caps if Shared Variables were suggested .
jm
10-17-2008 08:26 AM