05-14-2012 12:27 AM - edited 05-14-2012 12:27 AM
A control, "range column", is a connector.
I use local variables to clean up the code.
Is it ok to use local variables like this?
05-14-2012 12:31 AM
Yes but still its straight forward to connect the wire. Any specific reason for using the local variable?
05-14-2012 12:41 AM
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
05-14-2012 12:43 AM
@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.
05-14-2012 12:48 AM
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!!!
05-14-2012 12:51 AM
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
05-14-2012 08:23 AM
@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.
05-14-2012 09:33 AM
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?
05-14-2012 09:54 AM
@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
05-14-2012 10:20 AM - edited 05-14-2012 10:21 AM
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. 😄