LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global variable array alternatives

I'm doing some work on a large existing application that uses several global array variables. These global variables contain arrays of values that the user has available to choose from at a certain point during runtime. These values are used in the background to choose tasks that need to be done as well as set levels for some processes. An example of one of these global array variables is an array of 10 length values and the description for each. There are references to these array variables in a few subVi's as well as quite a few in the main runtime Vi. My task is to provide the user with the means to add or remove values from each of these lists. I've tried writing to the global array variable, but when the application is restarted the default values are restored. Can anyone offer some suggestions for alternatives? I only need to add and remove values at one time during runtime when the user calls the subVI that they use to select the value they wish to use. This subVi is called whenever the operator starts a new test.
 
The first method I tried was using a combo box with specific values assigned to each item in the list. This was easy for me to provide the user with the ability to add and remove entries. The problem was how to reference those values in another subVi that gets called later down the line.
 
I'm considering using a configuration file to hold all the values for more than one of these arrays. One question about this method...do I still have to read in the values into a variable that can be used in multiple locations at various times during runtime? I do not want to read this file every time I need one of these values. That doesn't seem like effective way to use the configuration file.
 
To some it up...How do I effectively reuse an array of values throughout multiple Vi's that will not get reset during shutdown, while still allowing the user to change the values dynamically during runtime?
0 Kudos
Message 1 of 8
(4,828 Views)

Please review the Action Engine Nugget.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 8
(4,816 Views)

Ben,

I appreciate the information. I've read through everything you posted as well as several previous posts regarding the LV2 global variables. I still do not see these as viable options for my application. Is there any examples available that show how these can be used to maintain a list of items to be reused? How does this array first get propogated? Do I have to start with an empty array and create each entry from the UI? That would mean each time this application is installed I would have to input the intial 10 lengths via the UI. This doesn't seem like a very effective way programming? I also have to run this Vi in some fasion to generate some form of output that can be read by the user or operator. By using shift registers the values are hidden and not easily manipulated.

Anyone else have any options?

0 Kudos
Message 3 of 8
(4,801 Views)
I am not sure why you think that the LV2 style global would not work.  See the slightly modified attached example (LV8.0) and see if this meets your needs, or at least points you in the right direction. The zip file contains a vi and a text file.  If I understand what you are doing, you want to be able to load predefined actions with descriptions at start... during the program, be able to add new actions with descritptions, recall this action/description 2D array from multiple points, and be able to save the whole thing the next time you run.
This attached VI:
set the action according to what you want to do.  possibilities (get the action/description array, add a new action/description element, initialize the array (IE read the stored action/description array from file), Store the current action/description array TO file)

On program initialize, use the initialize(ReadFile) action.  you can hardcode the file path or feed it from the caller (my recommendation),
Use the get(ReadGlobal) action to read this array from whereever you like.
Use the addElement anytime you need a new action
Use the saveCurrentState to rewrite the file.

You did not mention deleting an action/description pair, but it would be easy enough to add it within this program structure.

Message Edited by Stradis on 05-30-2007 11:56 AM


Paul
Message 4 of 8
(4,792 Views)

Thank you Paul!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 8
(4,772 Views)
Do you happen to have an example in LabView 7.1 format? This program was written in 7 and I cannot change it. Thanks.
0 Kudos
Message 6 of 8
(4,721 Views)

Hello kdugal,

This is Dominic L. from Applications Engineering at National Instruments. I saved Paul's example in LabVIEW 7.1 for you. If you have further questions please feel free to post them. We would be happy to assist you.

Thanks so much and have a great day!

Best Regards,

Dominic L.
0 Kudos
Message 7 of 8
(4,684 Views)
Thanks for taking care of that Dominic. And thank you Ben and Paul for your help as well. I am looking forward to learning more about this methodology.
0 Kudos
Message 8 of 8
(4,673 Views)