LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

General question about programming

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 

0 Kudos
Message 1 of 12
(3,283 Views)

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 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 12
(3,278 Views)

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?

0 Kudos
Message 3 of 12
(3,271 Views)

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

 

code capture tool

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Download All
Message 4 of 12
(3,261 Views)

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.

Regards,
André (CLA, CLED)
0 Kudos
Message 5 of 12
(3,234 Views)

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

0 Kudos
Message 6 of 12
(3,214 Views)

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


it earns a living doesn't it :smileywink:

 

Maybe some pointers to tutorials would help more.

 

http://zone.ni.com/devzone/cda/tut/p/id/7466

Regards,
André (CLA, CLED)
0 Kudos
Message 7 of 12
(3,205 Views)

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


it earns a living doesn't it :smileywink:

 

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! Smiley Wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 12
(3,198 Views)

"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 Smiley Wink.

 

jm

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 9 of 12
(3,193 Views)
The term global points to functional global in my dictionary.
Regards,
André (CLA, CLED)
Message 10 of 12
(3,185 Views)