Text from file
Posted: Fri Apr 08, 2016 10:55 am
i'm using this to get text from files to be passed back to routines that print the text. but it doesn't work- "control.lua:27: attempt to index global 'io' (a nil value)". this is the code:
function GetTextFromFile(filename)
--defines the variable to hold the text(what will be returned)
local text
local textfile
--opens a text file using the name passed as a parameter
textfile = io.open (filename, "r")
--sets the text variable to what is in the file
text = io.read()
--closes the file
io.close(textfile)
return text
end
can anyone help? i'm pretty sure io.open is the correct command..
function GetTextFromFile(filename)
--defines the variable to hold the text(what will be returned)
local text
local textfile
--opens a text file using the name passed as a parameter
textfile = io.open (filename, "r")
--sets the text variable to what is in the file
text = io.read()
--closes the file
io.close(textfile)
return text
end
can anyone help? i'm pretty sure io.open is the correct command..