LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can an array of input controls be programatically initialized

A common operation required by my anticipated applications is to initialize a set of edit boxes to values from another application or file.  The user can then make modifications to the inputs before continuing with the application.  For instance, a technician is suppose to manually acquire up to 10 resistance readings with each reading being a certain number of seconds apart.  The number of seconds and number of points depends upon the device being measured.
 
What seems logical to me would be to have an array of 10 edit inputs.  These should be automatically initialized to the nominal number of seconds when he indicates what device he is measuring.  After initialization, he could make modifications to the nominal times with actual times.
 
I have attempted to do this by attaching a local variable to an edit box and then moving the edit box into an array hoping I would end up with an edit array to which values could be written.  Labview accepts the edit box but not the local variable.
 
Anybody have any suggestion?
 
Thanks,
 
KGTang
 
 
0 Kudos
Message 1 of 7
(3,722 Views)
Hi KGTang,

There are a *LOT* of ways to do what you want.

1.  Storing default values:  If your program is simple, I would recommend a standard ini file for storage of values between runs.  It's easy to read and edit in just a text editor.  You should be able to find some samples of ini files among the File Configuration VI's that are used to manipulate them.

2.  Loading default values: If you have an array control, you can load values into it by writing the local for the entire array, not just a single value.  See the attached image for a trivial example.

0 Kudos
Message 2 of 7
(3,709 Views)
You can use .xml files to store configuration settings for all controls on a front panel.  For example, I use .xml files to store different daq parameters that different users require.

The other beauty to this approach is that you can use this code to change the default values of a compiled VI.  (LabVIEW executable)  It takes some coding but is very powerful in the long run. 

I use a startup screen on my application that allows the user to select a start-up configuration.

The user can also save any combination of front panel control settings during run-time by writing the control values to an .xml file.

Use the
Control Value:Get All [Flattened] Method to get the values of all controls on a front panel.
0 Kudos
Message 3 of 7
(3,693 Views)
Hi KGTang,

Another method you might want to check out is using the property saver vi's found below.

http://www.kshif.com/lv/index.html

It includes nice examples of saving values and properties for your front panel controls.

Cheers,

--Russ
0 Kudos
Message 4 of 7
(3,671 Views)
Thanks for the input.
 
Ended up using local variables for the arrays within an event stucture.  This is all contained within a while loop that keeps the VI running.  Seemed like a lot of jumping through hoops to do something that could be done so simply in C.
 
Unfortunately, the  application hangs in the event structure unit a trapped event happens.  Nothing else gets updated in the VI until an event is completed.  Maybe there is some way to have a "null event" included within the structure that would prevent the hang-up in the event structure.  I haven't found it yet.
 
I see that images can be posted in this group.  Can VI's be posted?
 
Thanks,
 
kgtang
 
 
0 Kudos
Message 5 of 7
(3,632 Views)
Kgtang,

Each of the solutions presented above would be viable options for your application. It sounds as if you have chosen a solution that may still be giving you trouble. I am a little unsure what you mean when you say that the VI is hanging up in the event structure. If you are still experiencing this trouble, please elaborate on this problem.

In regard to your other question, yes, you are able to post VIs to the forums. When you do, please comment them so that users can easily determine the VI behavior. Thanks,

Mike
0 Kudos
Message 6 of 7
(3,611 Views)

Mike,

> I am a little unsure what you mean when you say that the VI is hanging up in the event structure.

I didn't completely understand how Labview handled handled an event structure.  The event structure is inside a while loop and I was expecting to simply pass through the event stucture if no event occured.  Now that I understand that it doesn't, it's not a problem.  Concurrent stuff can just be done outside of the while loop containing the event structure.

Thanks,

KGTang

0 Kudos
Message 7 of 7
(3,577 Views)