Hi!
Is it possible to somehow save the value of a certain variable so that when i restart the EG, the state of variable is not lost?
e.g. if i assign a eg.globals.myVar = 1 and then restart the EG, the myVar variable no longer exists. What should i do to save that variable?
Is writing it to a file an only way?
Thanks!
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Persistent variables - save/restore variable value on restar
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Persistent variables - save/restore variable value on re
Here are two of the ways to solve it:
- Check the file FindWindow.py (it's part of the plugin Window).
There search for the keyword "eg.PersistentData" and see how it treats the variable "hideOnDrag". - You can use the Webserver plugin or Tornado plugin (which actually no, if you do not like it)
and actions "Set persistent value" and "Get persistent value".
It is not necessary to use these your variables as well as inside Webserver/Tornado plugin.
Re: Persistent variables - save/restore variable value on re
I've done it like this:
eveything on the Auto Start (i have it in spanish, i don't know exactly the words so i'll try to explain myself).
1- Python Script: with each variable. IT CREATS THE VARIABLE.
2- Create a Folder and in it one file.txt for each variable. SOMETHING THAT IT'S NEEDED FOR THE NEXT STEP.
3- Python Program and so on.
IT READS THE 1ST LINE OF THE SPECIFIC FILE AND TURNS WHAT IT'S WRITTEN ON IT IN TO THE VARIABLE.
TO WRITE THE VARIABLE ON THE FILE Not in start up
Hope it helped
eveything on the Auto Start (i have it in spanish, i don't know exactly the words so i'll try to explain myself).
1- Python Script:
Code: Select all
eg.globals.Dashboard_X1 = "0"2- Create a Folder and in it one file.txt for each variable. SOMETHING THAT IT'S NEEDED FOR THE NEXT STEP.
3- Python Program
Code: Select all
f0 = open("C:\...................\EG_variables-DASHBOARD_A1.txt","r")
data = f0.readlines(0)
eg.globals.Dashboard_A1 = data[0]
f0.close()
f1 = open("C:\...........\EG_variables-DASHBOARD_A2.txt","r")
data = f1.readlines(0)
eg.globals.Dashboard_A2 = data[0]
f1.close()IT READS THE 1ST LINE OF THE SPECIFIC FILE AND TURNS WHAT IT'S WRITTEN ON IT IN TO THE VARIABLE.
TO WRITE THE VARIABLE ON THE FILE Not in start up
Code: Select all
w = open("C:\.......................\EG_variables-DASHBOARD_B4.txt","r+")
w.write("THE VARIABLE")
w.close()Re: Persistent variables - save/restore variable value on re
Great!
Juanson:
thanks for this tip regarding the save to file method.
Pako:
I looked at the hideOnDrag, but unfortunately it doen't tell me much.
Would you be so kind and help me with an example please?
Btw:How can i remove/delete a persistent variable from the tornado?
Kind regards to all!
Juanson:
thanks for this tip regarding the save to file method.
Pako:
I looked at the hideOnDrag, but unfortunately it doen't tell me much.
Would you be so kind and help me with an example please?
Btw:How can i remove/delete a persistent variable from the tornado?
Kind regards to all!
- Pako
- Plugin Developer
- Posts: 2294
- Joined: Sat Nov 11, 2006 1:31 pm
- Location: Czech Republic
- Contact:
Re: Persistent variables - save/restore variable value on re
There you can see everything what is needed.TRIROG1 wrote:I looked at the hideOnDrag, but unfortunately it doen't tell me much.
Maybe you are missing some python skills. This is not the appropriate place to address this problem.
PakoTRIROG1 wrote:Btw:How can i remove/delete a persistent variable from the tornado?
Re: Persistent variables - save/restore variable value on re
Of course i'm still a beginner ... but hey ... gotta start somewhere 
Thanks!
Thanks!