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

fs.open and then i need a bit of help

Started by Dustmuz, 12 June 2015 - 07:50 PM
Dustmuz #1
Posted 12 June 2015 - 09:50 PM
Code first - Link

my "problem" comes at line 26 and that entire function i havent written to end yet, as i got stuck
im making a program for my power monitoring (and soon to be button controlled aswell)

i would like to be able to change the amount of capacitor banks while the program is running.
but the problem is, im keeping the amount of capacitorbanks in a seperate file (only way i could get the damn thing to work, without writing the amount each time)
so i cant delete this file, while the program is running, to change the amount (was my first thought)

next thought was to delete the content and rewrite it, but that again, gets my program to error out (tried)

so could i "replace" the entire file without the program giving me an error, or is there an approach i forgot to look at
KingofGamesYami #2
Posted 12 June 2015 - 10:31 PM
You can do the exact same thing you did on line 19

 config = fs.open("amount","w")
  amount = read()
  config.writeLine(amount)
  config.close()

When you write to the file, it will overwrite all previous data.
Dustmuz #3
Posted 12 June 2015 - 10:49 PM
i got told by Dragon :)/>
He finaly woke up and answered on skype, at the same time you wrote this :)/>

but thanks a lot :)/>