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.

How to save a variable for later use.

If you have a question or need help, this is the place to be.
Post Reply
User1306
Experienced User
Posts: 53
Joined: Sat Oct 13, 2012 4:37 pm

How to save a variable for later use.

Post by User1306 »

maybe this is simple, i'm not sure.
but how do i save a variable value for use later?

i have a couple of python scripts that gather info, whether it was the indoor Temperature, or the condition outside..... i need to read these variables in different macros for later use.

now i use the File Write and File read and have EG write the values to a notepad file, but i'm thinking there must be an easier way to do that, instead or reading and writing to file all the time.

if this is my best option, i'll just delete this Topic.

thank you in advance.
Javier
Experienced User
Posts: 73
Joined: Sun Dec 01, 2013 3:45 pm

Re: How to save a variable for later use.

Post by Javier »

This code sets a "global variable" named "test1" to "123" then prints eg.globals.test1 in the Log.

I believe your are looking to set eg.globals.your_variable_name_here

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1700">
    <Action Name="Python Script Set EG Global Variable">
        EventGhost.PythonScript(u'eg.globals.test1 = "123"\nprint eg.globals.test1')
    </Action>
</EventGhost>
User1306
Experienced User
Posts: 53
Joined: Sat Oct 13, 2012 4:37 pm

Re: How to save a variable for later use.

Post by User1306 »

thank you very much for the help.
i will give it a try as soon as i get home from work.
Post Reply