LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it ok to use local variables for connector variables?

labview01.png

 

A control, "range column", is a connector.

 

I use local variables to clean up the code.

 

labview02.png

 

Is it ok to use local variables like this?

0 Kudos
Message 1 of 16
(3,536 Views)

Yes but still its straight forward to connect the wire. Any specific reason for using the local variable?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 16
(3,532 Views)

Hmmm.. Why do you not put the "range column" control out of the case structure (like the "start" and "end" controls)?

If you did that you wouldn't need a local variable.

 

Side note : I think I read somewhere that it's not optimal to put a controls that's on the connector pane inside of of case (may it be an input control or an output control) because then LabVIEW has to add code to give a default value to your control if the case that executes is not the one contains the controls. Oh yes, here.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 3 of 16
(3,530 Views)

@P Anand wrote:

Yes but still its straight forward to connect the wire. Any specific reason for using the local variable?


It's cleaner with less wires.

0 Kudos
Message 4 of 16
(3,525 Views)

iCat wrote:

It's cleaner with less wires.


Why would that be "cleaner", that statement makes no sense at all! Read my old post here for details. 😄

 

In any case, as Titou already said, the Range column control terminal belongs on the toplevel diagram, outside any structures. Then simple branch the wire to the two places where you need it. Much cleaner!!!

 

 

Message 5 of 16
(3,520 Views)

Well If you want even less wires you can connect your string controls (start & end) directly to your the case selectors of you case structure and have cases to handle the empty strings. Thus you'll get ride of the two "is different?" primitives and the string constant.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 6 of 16
(3,519 Views)

@iCat wrote:

@P Anand wrote:

Yes but still its straight forward to connect the wire. Any specific reason for using the local variable?


It's cleaner with less wires.


It's also wrong, since you've created a race condition.

Message 7 of 16
(3,488 Views)

How many different threads are you going to create trying to justify your silly usage of local variables. You obviously have not listened to what may people have told you about the risks involved. You simply refuse to listen. Why do you even post questions here if you will not pay any attention to the answers. How many times before you stop getting answers because everyn is tired of saying the same thing to you over and over again?

Message 8 of 16
(3,472 Views)

@iCat wrote:

@P Anand wrote:

Yes but still its straight forward to connect the wire. Any specific reason for using the local variable?


It's cleaner with less wires.


If you hve any hope of ever getting certified as a LV developer, get out of the habit of using locals. You will loose point on your exam for using them when not absolutely required and "It's cleaner with less wires." will help.

 

Learn to write LV code without locals and your life will be easier.

 

OR ...

 

Ignore us keep using them and start a journal of your experiences so you can someday come back and tell US why we should not use locals.

 

So take our advise now and save yourself headaches or ignore us and learn for yourself.

 

I'll even give you a hint!

 

When you code start acting wonky, examine the local variables first.

 

Giving you enough rope to hang yourself,

 

 

Ben

 

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

As Ben  said I hanged myself by using the initial stage of my coding then I started learning and removed the rope myself and made my life easy. 😄

-----

The best solution is the one you find it by yourself
Message 10 of 16
(3,449 Views)