LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save variable value and locking the code

Hi,
I want to save some values of indicator on front panel in place of typing them each time. e.g,

maximum velocity 1 mm/sec

maximum accel .....

Each time, while opening I want the values used in last experiment as default.

I do not want to set a fixed default value, it should be from last experiment.

Also, I have to lock the code so as no bady else can change it. But I do not know how.

Any help is appreciated,
Dushyant
0 Kudos
Message 1 of 24
(4,602 Views)
Hi,

To lock the code, so that no one else can change without your knowledge, follow these steps.

Open the VI, Select 'VI Properties' from the 'File' menu.

Choose 'Security' from the Categories in the drop down menu on VI properties dialog.

Choose the level of security for your VIs(unlocked by default, locked and password protected).

Just a thought abt your other problem. Try storing the control values at the end of each run or before quitting the VI, to a .txt or .ini file. Modify your VI, so that the firt step is to read the values from that saved file and update the controls.

Deepak
0 Kudos
Message 2 of 24
(4,582 Views)
There is a VI method that will set all the values as default. However a VI can not call on itself, while it is running. So take a look at the attached code.

The Main Project VI represents your code, and I added a password 123

You would need to put that code at the very end of your code. Notice that I call the other VI and then finish. The other VI loads your VI, with password, and then sets the values to default once it stops running.

Let me know if you have any questions.
0 Kudos
Message 3 of 24
(4,576 Views)
Thanks a lot to all who responded.

Your suggestions were quite valuable.
0 Kudos
Message 4 of 24
(4,568 Views)
Sorry Evan,
I could NOT accomplish as you suggested. Would you please demonstrate it? I am attaching required .vi and I will attach the sub .vi in next message.
Thanks a lot,
Dushyant
0 Kudos
Message 5 of 24
(4,552 Views)
Hi Evan,
Here is the sub vi.
Thanks,
0 Kudos
Message 6 of 24
(4,556 Views)
Here is your modified VI. I placed code that will run at the end that launches the Set Default VI.

For my code to work you need to have the Set Defaults in the same directory. If you want it somewhere else simply change the file path that goes to the Open VI.
Message 7 of 24
(4,552 Views)
Evan,
Thanks a lot.
Dushyant
0 Kudos
Message 8 of 24
(4,546 Views)
Hello Evan,
Sorry for bothering you again.

After I downloaded the file modified by you, I was not able to save new value if I change that. I could not figure out how I can do that. I guess that I am dumb.

Thanks in advance,
Dushyant
0 Kudos
Message 9 of 24
(4,533 Views)
The code I wrote is simple and complex all at the same time, so don't worry about being confused. Calling other VIs by reference and setting controls is advanced programing.

You should be able to set the front panel to any values you want and then to run the VI. At the very end it should set whatever values are on the front panel as default.

If that is not working, then I would check to see if any errors where generated in the code I added. Most likely it could not find the subVI I wrote. If that is so, then remeber to place the SubVI I attached in the zip file in the same directory. If there is an error let me know.

If you want to manually set the values to defualt, you can set all the controls and then go to Operate >> Make Current Values Default.
0 Kudos
Message 10 of 24
(4,525 Views)