IpsoFacto Posted March 29, 2016 Report Share Posted March 29, 2016 Is it possible (using Scripting, I assume) to modify the default value of an object programmatically? I have an object whose default value is loaded at runtime to represent some system settings and I've created a UI to modify those settings. Currently I manually take the settings and copy them into the object and right-click -> Set as Default Value, than save it. Was wondering if there was a way to do this programmatically? Quote Link to comment
hooovahh Posted March 29, 2016 Report Share Posted March 29, 2016 You can set the default value of a control using scripting. But I don't think this is what you want. Very few scripting functions work in the run-time engine. Scripting is generally a thing that makes LabVIEW code, or edits LabVIEW code. These are not the types of things you do in a run-time engine. In a built EXE for C++ you wouldn't generate new source code that is compiled and then used in that EXE. It would be something like self modifying code, and probably should be avoided. But what you can do is use a function like the OpenG Write Panel to INI, and Read Panel From INI. This will take the control values for every control on your front panel, and save them to a human readable INI file. Then on startup of your program you can use the Read Panel From INI and it will set the control values to what they were last saved to. Where you save the INI is up to you, but you may get into some permissions issues if you try writing and reading to files under Program Files, which is why most programs are gravitating to using the Application Data folder, or ProgramData for all users. These two wonderful OpenG functions can be found in the Variant Configuration package. 1 Quote Link to comment
IpsoFacto Posted March 29, 2016 Author Report Share Posted March 29, 2016 Hooovahh, Thanks for the reply. Unfortunately my settings object has in it's class data other objects. I tried collapsing the objects to XML however one of these objects can grow rather large and I get the 1803 error when expanding it from XML. Quote Link to comment
ak_nz Posted March 31, 2016 Report Share Posted March 31, 2016 (edited) My preference would be to have a "Set to Default" method of the class that initialises the object with reasonable defaults that you call on teh startup of your application. Then your settings UI can call methods on the object to tweak teh settings as the user desires. As a general rule I dislike the "Default Value" properties of controls because they can be very hard to control and enforce over the development lifetime of an application. Edited March 31, 2016 by ak_nz 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.