michal Posted May 18, 2005 Report Share Posted May 18, 2005 Hi all, is there a way how to assign defaults to controls programatically? I mean, every time I launch the program (subVI in my case) I need the controls to be set to values used in previous run of the program. I have tried the Make current values default method after once controls were set, but the error message popped up saying I only can use this method in Edit mode. Would anybody gimme a hint Thanks Michal Quote Link to comment
Sarah83 Posted May 18, 2005 Report Share Posted May 18, 2005 Hi all,is there a way how to assign defaults to controls programatically? I mean, every time I launch the program (subVI in my case) I need the controls to be set to values used in previous run of the program. I have tried the Make current values default method after once controls were set, but the error message popped up saying I only can use this method in Edit mode. Would anybody gimme a hint Thanks Michal 4784[/snapback] Hi Michal, what kind of controls do you mean? You can save values as default if you go to the toolbar -> complete -> set values as default. Edit: If you want to set some controls e.g. switches to true, you need to create a local variable of this control. This variable should be changed into "write" (right click on the variable) and wired to a true constant (boolesch) Quote Link to comment
michal Posted May 18, 2005 Author Report Share Posted May 18, 2005 Every run of program, I set values on controls (numerical ctrls) - different from run to run. All I need - when I run program every next time - is that the controls values turn up as they were the last time of program run. Hi Michal,what kind of controls do you mean? You can save values as default if you go to the toolbar -> complete -> set values as default. Edit: If you want to set some controls e.g. switches to true, you need to create a local variable of this control. This variable should be changed into "write" (right click on the variable) and wired to a true constant (boolesch) 4785[/snapback] Quote Link to comment
Sarah83 Posted May 18, 2005 Report Share Posted May 18, 2005 Every run of program, I set values on controls (numerical ctrls) - different from run to run. All I need - when I run program every next time - is that the controls values turn up as they were the last time of program run. 4786[/snapback] Do you close this vi completely or do you only stop your vi? Maybe you can try to create a property node of your control, select value. Then write this value into a nummeric element. This should remember your value. Now you can make a case that this element won't change until you run the vi once more. Quote Link to comment
regisphilbin Posted May 18, 2005 Report Share Posted May 18, 2005 Another option would be to write the data from Subvi's Controls (once you're finished using it and close it) to a text file. Then, when you call the Subvi the next time around, read from the text file and populate the controls values using property nodes. Quote Link to comment
Mark Balla Posted May 18, 2005 Report Share Posted May 18, 2005 There may be a better way to do this but here is what I came up with. Download File:post-584-1116445688.llb Download File:post-181-1161869716.doc Quote Link to comment
Albert-Jan Brouwer Posted May 18, 2005 Report Share Posted May 18, 2005 is there a way how to assign defaults to controls programatically? I mean, every time I launch the program (subVI in my case) I need the controls to be set to values used in previous run of the program. 4784[/snapback] For an example of a VI that does that in a convenient manner see the LuaVIEW toolkit. When you extract the archive, the VI can be found at library/persistence/Libary Persist Position and Controls.vi. The way to use it is to call it with the "load" enum wired to the action input when you start your user interface VI, and call it with the "save" enum wired to the action input when you stop your user interface VI. Give all controls whose value should be persisted a description that starts with the string "(persistent)". No further programming required. The VI works by locating these controls via VI server and loading/saving their values from/to a file in the default data directory. Note that the position and size of the window is also persisted. Feel free to copy/customise the VI: it uses only a handful of subVIs and is small peripheral part of the toolkit. I have seen variations on the same theme floating around, so you may wish to shop around. Albert-Jan 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.