function getFileString(path)
local file, err = io.open(path, "r")
local all = file:read("*a")
file:close()
return all
end
function main ()
local directory = "C:\Documents and Settings\All Users\Documents\"
print("Reading File...")< br /> local file_all = getFileString(directory.."myFile.txt")
print("File Read! ")
end
main( )
It doesn’t seem to matter whether I am functional or not. I should mention that this is mainly because I am reading about 150MB files.
< p>Before running the opened and read file, I ran into the problem of getting Lua to print. This would print the strings “Reading File…” and “File Read!” but only after it completed the getFileString() function. Hope it prints “Read file…” before running. I reduced it to file: read(“*a”) This will mess up all prints in my (larger) script .
function getFileString(path)
local file, err = io.open(path, "r")
local all = file:read("*a")
file:close()
return all
end
function main ()
local directory = "C:\Documents and Settings\All Users\Documents\"
print("Reading File...")< br /> local file_all = getFileString(directory.."myFile.txt")
print("File Read! ")
end
main( )
It doesn’t seem to matter whether I am functional or not. I should mention that this is mainly because I am reading about 150MB files.
I think the output is just buffering. Try to add io.stdout before printing: setvbuf(‘no’), this should turn off output buffering.