Jump to content

Next Newbie Q: Local variable for an array?


Recommended Posts

OK, so now I've decided to have an array of references to 12 WaveGraphs. And it works. For the sake of keeping the diagram clean, I would like to separate the initialization of this array from the use of the array. But when I right-click on the output of the Build Array VI, the option "Create Local Variable" is not available.

Is there an alternative to wiring the array directly to where it is being used, or is there some way I can separate my initialization code from my event-handling code?

Link to comment

Why don't you post a quick snapshot of what you mean?

There is no need to "initialize" an array in LV.

Using Local Variables of an array is a bad habit to get into. (Race conditions, calls to memory manager affect performance, creates unnecessary copies of data).

Maybe a quick look at the Getting Started with LV manual would help.

N.

Link to comment

QUOTE (Neville D @ May 14 2009, 03:32 PM)

I should have mentioned that it was what I decided upon at the end of this thread:

http://forums.lavag.org/Instantiate-WaveGr...aded#entry62912

In a nutshell, I need 12 WaveGraphs, independently controlled (including zoom), yet treatable as an array. So I am using an array of 12 references to 12 independent WaveGraphs. The attached diagram shows my current solution, which is to wire the array of references directly to where it is needed in the event loop.

Link to comment

If you want help you will need to post either a more complete snapshot of your VI or the code itself. From the tiny snippet you posted it is hard to see what you are doing. Not to sound nasty of anything but I would suggest that you take the LabVIEW Basics I and II courses or at a minimum pick up the book "LabVIEW for Everyone". You would benefit greatly from some training to help get you started. While LAVA is a great source of information it is not the best place to try and learn LabVIEW from the ground up. There are better resources for that.

Link to comment

QUOTE (Michael Malak @ May 14 2009, 02:57 PM)

http://forums.lavag.org/Instantiate-WaveGr...aded#entry62912

In a nutshell, I need 12 WaveGraphs, independently controlled (including zoom), yet treatable as an array. So I am using an array of 12 references to 12 independent WaveGraphs. The attached diagram shows my current solution, which is to wire the array of references directly to where it is needed in the event loop.

One thing no one suggested was subpanels. It's kind of an advanced LabVIEW topic, and I wouldn't normally recommend it for a self-proclaimed new user, but I think it gets you closest to what you need. You can't have an array of subpanels, but you can drop 12 of them on your panel. First I would try it with two and see if it's feasible.

Here's what you could do:

1. Drop the Subpanel controls on your front panel and arrange them.

2. Make a new VI with your graph on the front panel, and select Fit Control to Pane by right-clicking on the graph.

3. Make this VI reentrant in the VI Properties -> Execution. This will enable you to create clones of your panel.

4. Run Open VI Reference with Options = "8" once for each graph you need, and then pipe those references into the SubPanel nodes on your diagram.

5. Figure out some way to get the data into your cloned panels (there are lots of ways). You could use notifiers named for each clone name, or else you could obtain the control references for each with a few VI server calls and then send data into the Value property of those control refs.

Oh curse the day I read your post, Michael Malak!

It was an interesting problem, so I had to code it up. I didn't close any references (probably doesn't matter), nor handle any errors (there are none), and I only added comments where the code was completely obscure.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.