8 posts
Posted 03 October 2013 - 08:08 AM
Title : Is there a way to edit and save printed Text?
For example:
local x = io.read()
fs.makeDir("saves")
local file = fs.open("saves/text","w")
file.writeLine(x)
file.close()
shell.run("clear")
file = fs.open("saves/text","r")
local fileData = {}
local line = file.readLine()
repeat
table.insert(fileData,line)
line = file.readLine()
until line == nil
file.close()
local x = fileData[1]
print("Text : \n"..x)
Now, how i can edit and save x?
8 posts
Posted 03 October 2013 - 08:12 AM
Title : Is there a way to edit and save printed Text?For example:
local x = io.read()
fs.makeDir("saves")
local file = fs.open("saves/text","w")
file.writeLine(x)
file.close()
shell.run("clear")
file = fs.open("saves/text","r")
local fileData = {}
local line = file.readLine()
repeat
table.insert(fileData,line)
line = file.readLine()
until line == nil
file.close()
local x = fileData[1]
print("Text : \n"..x)
Now, how i can edit and save x?
171 posts
Location
Study: United Kingdom Native: Latvia
Posted 03 October 2013 - 09:08 AM
You just did that with the code you posted, what exactly are you trying to do?
If you are trying to save to a file what is on a screen, you will need to override all display functions and store them in a screen buffer, which then can be serialized and saved to a file.
And by x you mean "saves/text" or as a variable?
If a variable, then just serialize it.
220 posts
Location
Germany
Posted 03 October 2013 - 01:02 PM
Do you want to save the content on the screen?
8 posts
Posted 03 October 2013 - 02:18 PM
I want to edit a string i previously saved.
EDIT :
2nd Example :
x = "I like Turtles"
fs.makeDir("saves")
local file = fs.open("saves/string","w")
file.writeLine(x)
file.close()
write("Your Text : ")
file = fs.open("saves/string","r")
local fileData = {}
local line = file.readLine()
repeat
table.insert(fileData,line)
line = file.readLine()
until line == nil
file.close()
saved_x = fileData[1]
write(saved_x)
--[[
And NOW i want to edit "saved_x" via Keyboard.
For Example i want to replace "Turtles" with "Monkeys" and save it again "as saved_x".
]]
8543 posts
Posted 03 October 2013 - 02:42 PM
Threads merged.