49 posts
Posted 01 May 2016 - 01:37 AM
Hello guys.
There's a way to save a variable globally in one computer?
One Example:
I have one program called "test" , this program have this lines:
Variable_2 = "Maria"
Now, in other program, can i call the variable in the program "test" ? Like:
if Variable_2 == "Maria" then
Etc…
756 posts
Posted 01 May 2016 - 01:41 AM
Yes, simply omit the "local" keyword when declaring variables.
15 posts
Location
somewere in Belgium
Posted 01 May 2016 - 01:46 AM
yes if you do this it will work unless you reboot the only way you can keep data from rebooting is writing it in the memory
49 posts
Posted 01 May 2016 - 01:50 AM
yes if you do this it will work unless you reboot the only way you can keep data from rebooting is writing it in the memory
And if i use the the
os.pullEvent = pullEvent
to terminate the "startup" program. It losts the memory?
212 posts
Location
Somewhere in this dimension... I think.
Posted 01 May 2016 - 02:18 AM
It should be mentioned that 90% of all ways to run a program WON'T keep the variable between programs although there IS a way. Check
os.run.
os.pullEvent = pullEvent does
nothing by default either except causing programs to crumble to tiny little pieces as they desperately try to get events and definitely won't terminate the "startup" program.
Edit: Example code
File 1:
tEnv = {}
os.run(tEnv, "File_2")
os.run(tEnv, "File_3")
print(tEnv["test"])
Outputs: "Hello Forums!"
File 2:
test = "I am a test variable!"
print(test)
Outputs: "I am a test variable!"
File 3:
print(test)
test = "Hello Forums!"
print(test)
Output 1: "I am a test variable!""Hello Forums!"
Output 2: "Hello Forums!"
Edited on 01 May 2016 - 12:25 AM