LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can you sort the "local variable" pick list?

My program has a lot of local variables. If I right click on a variable and click on "select item", a loooong list of all my local variables appears. They appear to be in the order in which they were created in my program.

Is there any way to modify the display to where the local variables appear in alphabetical order?
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 1 of 11
(3,676 Views)
Like other lists in LabVIEW, the list is based on the the tabbing order, which by default is the order in which you create objects. I don't think there's a way to change it to alphabetical (which sounds like a nice idea, actually), but you can change the tabbing order, thus changing the list, by selecting edit>>change tabbing order.

___________________
Try to take over the world!
Message 2 of 11
(3,666 Views)
The best solution is to not use a lot of local variables ;). Here is a neat trick to use local variables without having to use local variables :o. If you are using a state machine (case structure inside a while loop), create a cluster constant on the block diagram inside a state or case called "Local Defs". Inside the cluster, put constants for every local variable you will use. Label the constants like you would a local variable. Put a shift register on the loop border. Wire the cluster to the shift register on the right side. Do not initialize the shift register on the left side. In any case frame, you can wire from the left shift register into an unbundle or bundle to read or write to the Local. You never have to call the Local Defs state, the cluster will be defined because of the wiring. If using controls at many places, make a local constant for each control and have a state where the control is written to the local. Then you can read the local to use the value at any time. See attached vi for an example.
- tbob

Inventor of the WORM Global
Message 3 of 11
(3,659 Views)
Whoa. I did as you suggested. Do you have to actually go to each variable and renumber them one at a time? There's no auto-arrange or anything?
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 4 of 11
(3,656 Views)
Uhhh....I have over 250 local variables.....and I'm only halfway done with my program! Now you see why I'd like to organize them on the pick list! 🙂

But my program is just like you mentioned, a large stack of case structures nested in a while loop. For now I'm going to continue with lotsa locals because so far I'm not having any problems with them and I just want to get a functioning program done. When the program is done and working, I'll work a bit with your sample and get the feel of it and go back and clean up my code.

Thanks!


btw - Why does everyone hate locals? I find them convenient!
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 5 of 11
(3,654 Views)
People hate locals mainly because they disrupt the dataflow paradigm - instead of using wires to transfer your data you use locals. It is not uncommon to see code posted to this site which uses locals (or "Value" property nodes, which is worse) as they would be used in text based language. This could make the code harder to read, and especially to debug and can induce race conditions (which part of the code writes to the variable first?). Also, when you have a local, you create a copy of the data in memory. That said, I still happen to like locals. There are places where they're the most simple things to use (read data in two different loops) and as long as you use them correctly, you can get away with it.

___________________
Try to take over the world!
Message 6 of 11
(3,651 Views)
I guess that would make sense in a program that was more time sensitive. However my program monitors and controls a microprocessor running at 1200 baud, so speed is not an issue at all. 😉

I agree with you, I find locals easier to read in my program. A lot of my cases involve examining and handling different situations involving the same data to know what case to jump to or what to do in a certain situation.

The data copy of the original local variable is annoying to keep around in the code (I have a section of my code I call "the graveyard" where I threw all of those).
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 7 of 11
(3,648 Views)
I don't mean to revive an old thread from 2005, but have there been any changes to allow the list to be alphabetized now that LV 8.5 is out?
 
One thing I take execption with in this thread is that the excessive use of local variables is what is causing a long alphabetized list.  The list has nothing to do with the number of local variables used, but the number of controls and indicators used.  So if you have 200 controls and indicators, but only want to use a single local variable, you still have a tremendously long, unalphabetized list to look at.
 
Yes, you can find the terminal and select create local variable, but sometimes its more convenient to drop a generic local variable and select the one you want.  Or if you have one already wired up, but later decide you to change it, selecting the other should be more convenient than creating one and rewiring.
Message 8 of 11
(3,394 Views)
Whatever happened to Spaceman Spiff?  He was a funny guy.
- tbob

Inventor of the WORM Global
Message 9 of 11
(3,383 Views)


@Ravens Fan wrote:
I don't mean to revive an old thread from 2005, but have there been any changes to allow the list to be alphabetized now that LV 8.5 is out?

Believe it or not, it is sorted alphabetically in 8.5. Smiley Happy

___________________
Try to take over the world!
Message 10 of 11
(3,373 Views)