LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding numeric controls to an array, setting default values

Solved!
Go to solution

I know this is a very basic LV 001 question; I've looked at other posts on this issue, hoping for guidance.

 

I have a VI with a numeric array control (50 rows, 3 columns). The creator of the code included a comment: "certain default values have been set, edit values carefully."

 

I'd like to add more rows to the control. At row index 50, the three controls' values are grayed out and all three numerics have the same entry. So, I entered values for the three elements at row index 50, selected the overall array, and "set selected values as default" in the edit pulldown. It reverted back to prior/grayed out values when I reopened the VI.

 

Tried re-entering values in the controls at row index 50; selected each of the 3 controls and set defaults; didn't work. Also, tried right-clicking and setting default values; no soap.

 

What process can I use to enter more rows of data in this control array? I think the prior developer did the right thing, making it hard to inadvertently edit these crucial values. An array of constants might have been easier to change but more open to accidents.

 

Thanks,

 

Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 1 of 7
(3,514 Views)
Solution
Accepted by topic author MinerHokieRamp

You try to patch an originally wrong decision. Use configuration files to store important parameters/settings/values. When the program starts, it reads out the previously stored values from a config file(s). At program exit, or by user selection, store new values in new/old config files.

 

Do not use a control with "set as default" values to store important information. Even more, a final application should be an Exe(cutable), not a VI, so a config file approach in that case inevitable!

 

Regarding to your questions, if you do not wish to use config files:

just leave that original numeric control untouched. Just create a second one with the required new values. Using the simple array functions, you can merge the two value sets as you need...

 

Edit: about config files: http://zone.ni.com/reference/en-XX/help/371361N-01/lvconcepts/fileio_configuration_files/

 

Edit2: after reading again your post, I am not really sure what is going on. Without seeing the code itself I cannot really advice further. Depending on the usage case, you can still use this 2D numeric control, but I have no idea why it reverts back to the "original default", even if you set the new set "as default". Are you sure the original programmer did not put something in the code which rewrites the old values back on that control...? I am blind without seeing the code... What do you use these values for actually?

0 Kudos
Message 2 of 7
(3,497 Views)

After you set the new array value as default, you want to save the VI, else they won't be there when you open it again another time.

 

What you describe should work just fine. You must be doing something wrong. There is no menu to "Set selected values as default", it is actually called "Make selected values default". Could it be you use "reinitialize selected values to default" instead? That would cause what you observed.

 

Another option would be to right-click the array container and select "data operation...make current value default".

 

(If the grayed elements are nonzero, it means that the array element itself has a default value, but that should not be a problem.)

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

I hadn't thought of adding another control and concatenating it with the existing one.

 

The configuration file, an option I was considering, is probably the way I'll go with this. Much easier to update in the future and wouldn't require code changes whenever we need to add a row of data.

 

Thanks,

 

Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 4 of 7
(3,457 Views)

Agree, it is "Make selected values Default." I did save the VI after each attempt. I'll try again, just to see what's going on.

 

Thanks,

 

Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 5 of 7
(3,456 Views)

Can you attach a small VI that only contains the array control so we can test?

0 Kudos
Message 6 of 7
(3,443 Views)

The numeric control had been grouped with some text items, didn't realize it until later. Maybe that was why I couldn't make the values default.

 

I wrote the existing values to a file, edited the file, and changed the code to read the file.

 

Thanks,

 

 

Jeffrey Bledsoe
Electrical Engineer
0 Kudos
Message 7 of 7
(3,370 Views)