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

Edit for 1 datei

Started by gigagames, 31 March 2012 - 12:44 PM
gigagames #1
Posted 31 March 2012 - 02:44 PM
Hi,
i have a script :
Spoilerfunction _Bestellung()
local auftrag
term.clear()
term.setCursorPos(1,1)
print("Bitte gebe deine Bestellung ein :")
auftrag = read()
if auftrag == "" or auftrag == " " then
print("Bitte geben sie was ein")
sleep(2)
_Bestellung()
else
datei = io.open("huhu.txt", "a")
datei:write("\n"..auftrag)
print("Bestellung wurde gespeichert")
datei:close()
sleep(2)
_Bestellung()
end
end

_Bestellung()
Now I would like to make a 2nd script where the contents of huhu.txt is displayed
and that you can add delete things out there /, but how?



sry for the bad english , google translater
EatenAlive3 #2
Posted 31 March 2012 - 03:45 PM
For reading data, you can use 'datei:read()', but as I understand it, editing the data inside is tricky because of how LuaJ is set up. I'm not very experienced with doing that, but you would need to copy the data from datei, edit the contents of that, and then save it back in with datei:write().