LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save variable value and locking the code

Hi Evan,
Manually setting the default value is not desirable because I have to use the same thing in three codes that I am going to use to run the program. There would be more than 20 such entries.
I again tried to run the code (sub vi's are in same dir), but it's still not able to save new values. Ofcourse, the values that you saved are stil there. Since I am planning to use in all three codes that I am planning to use for experiment, I need to know how your code works and how to modify your code or change some parameters to save the default values in other codes. It would be nice if you can check your code to see why this is not working and explain to me how it works.
Anyway, thanks a lot for your help,
Dushyant
0 Kudos
Message 11 of 24
(1,830 Views)
Hi Dushyant,

I once created a small VI ("GetSetCtrls.vi") that I used to get and set control and indicator values of my VI using VI Server. It will currently store access ALL controls and indicators in the VI when called, but you can change it to only access a certain list of controls/indicators.

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 12 of 24
(1,816 Views)
I ran Evan's program and it works fine as long as I kept Set Defaults open. Modify your program per the attached drawing and everything should work just fine.
Message 13 of 24
(1,816 Views)
Thanks everybody for responding.

Philips,
I have certain doubts regarding the code that you attached, guess I am dumb 😉

Doubt 1.If I have to save 5 control values, should I use your function for each seperately?

Doubt 2. Do I need to creat some .txt file and then link it to "Ini file (empty)".

Would you please take a little trouble and modify my code? I am attaching that, you need to run complete_Experiment.vi, the other file is sub vi.


Thanks a lot anyway,
Dushyant
0 Kudos
Message 14 of 24
(1,809 Views)
Hi Dushyant,

I created a small example of how to use the GetSetCtrls.vi.

The GetSetCtrls.vi will load or save ALL controls of the main VI. If you want to specify only certain controls you will have to modify GetSetCtrls.vi.

Notice that I do not specify a file path - the default path will be used. A file will be created in the same directory as the main VI and the name of the file will be "[name of main VI].ini".

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 15 of 24
(1,772 Views)
Sorry,
I could not use your code. When I tried to run for the second time, it could not load.
Would you please modify my vi (Complete_Experiment.vi; please see the previous message)?
Thanks anyway,
Dushyant
0 Kudos
Message 16 of 24
(1,760 Views)
I think everyone might like to see your attempts to modify your own code. Evan's program works great with the little mod I recomend and Philip's example is very simple to add to your's. You can simply put your code in one frame of a sequence structure. Put Philip's VI in a frame before and a frame after. In the first frame, set the function to Load, and the in the third frame, set the function to Save. Owen's and Philip's take two different approaches but they both work.
Message 17 of 24
(1,751 Views)
Thanks Guys,
I was able to accomplish the desired result.
0 Kudos
Message 18 of 24
(1,735 Views)
I forget to thank Dennis. Dennis, Your suggestions were quite useful.
I am attaching my final code, just in case someone else need to accomplish the same.
I have used Philip's code for that purpose.

I added a frame before my code (also added a true/false loop in the same frame) and added another frame afterward. Now, i can choose whether I want previous values or not.

Message Edited by Dushyant on 03-11-2005 02:30 PM

0 Kudos
Message 19 of 24
(1,734 Views)
Dear Philip C.
 
Sorry to troubling you, I encounter some problem when i use your GetSetCtrls.vi.
It works well in debug model, and save current values as default successfully. But after it was build to APP, and run it, when i press the STOP button, an error appeared.
The error message is:
LabVIEW:  File not found. The file might have been moved or deleted, or the file path might be incorrectly formatted for the operating system. For example, use \ as path separators on Windows, : on Mac OS, and / on Linux.
---
NI-488:  Non-existent board.
 
what's wrong?
pls help me.
thanks and good night~!
0 Kudos
Message 20 of 24
(1,583 Views)