Hi, I am trying to load a file at runtime but somehow everything else is stoping when I do that. The file is around 500kb and I was hoping that someone around here could assist me or point me at the right direction.
When the file is getting loaded, line by line I want it to return a status - but that never happens until the file reading is done?
-- create a file path for corona i/o
local path = system.pathForFile( filename, nil )
-- will hold contents of file
local contents = ""
-- io.open opens a file at path. returns nil if no file found
local file = io.open( path, "r" )
if file then
-- Reading lines so that we can report back progress
for line in file:lines() do
contents = contents .. line -- display the line in the terminal
--This happens only when all lines are done and not for every line....
if stage == "F" then
-- Just a dummy sample code......
myParallax.position.x = myParallax.position.x + xx
end
end
io.close( file ) -- close the file after using it
end
return contents
My file that I am reading from is formatted so it has a new line for every line. I know how many lines there are in the file, but theres seems not to be a valid API that I could use to get a specified row?
e.g
local myLine10 = file:lines(10);
print("Line 10 contains: " .. myLine10)
would have solved my issues, any suggestions or am I totally lost here?
Joakim
[import]uid: 81188 topic_id: 25770 reply_id: 325770[/import]

