This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
jamesscape2's profile picture

How to sent variable between programs in one computer

Started by jamesscape2, 11 October 2012 - 08:45 AM
jamesscape2 #1
Posted 11 October 2012 - 10:45 AM
i would like to know

how do you send variable between programs inside one computer?

if it is possible not to use files


other wise if i have to use a file system

can u give me some example to code to look at and see how to do it

thanks
JoshhT #2
Posted 11 October 2012 - 11:36 AM
I believe you can set a global variable that will be stored and accessed by any programs so long as the computer is not shutdown or anything.
To prevent this, creating a file with variables within that would be reliable and not difficult.

Let me do a little testing and I'll get back to you.
jamesscape2 #3
Posted 11 October 2012 - 11:43 AM
Thanks

the sooner the better

thanks Again
Luanub #4
Posted 11 October 2012 - 11:50 AM
There's multiple ways of storing a var in a file. If you're only going to do one then you can simply do

local file = fs.open("filePath/filename", "w") -- open in write mode all data will be overwritten
file.write(varName)
file.close()

If you need something more let us know.
jag #5
Posted 11 October 2012 - 11:58 AM
You could use os.run()
jamesscape2 #6
Posted 11 October 2012 - 12:04 PM
i hav got it to save the var to the file fine i just need to know how to read then and insert them into my program now


thats were i am lost now
jamesscape2 #7
Posted 11 October 2012 - 12:21 PM
dw guys i got it

sorry about it if u put some effort into it to find an answer

thanks anyway