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

Saving variables for the next time the computer runs the same program?

Started by marceloclp, 03 May 2014 - 09:15 PM
marceloclp #1
Posted 03 May 2014 - 11:15 PM
Is there a way to save variables for the next time the computer runs the same program?

Ex: at the end of the program, I have a variable that adds one to itselft. So if the first time I ran the program, its value was 1, the next time, its value will be 2. And so on.

Is there any way I can do this?
OczkoSX #2
Posted 03 May 2014 - 11:30 PM
You have to create a file, and save a variable value to it. Read about file streams (fs)
Bomb Bloke #3
Posted 04 May 2014 - 02:36 AM
In particular, you'll want to read up on fs.open().