Hello everyone and thanks in advance to all the helpers.
I’m trying to make a data base on a text file which I’ll be able to print a single line by selecting the line number.
Does anyone knows how to do that ?
Also, if you have a better way to make a data base for a trivia like game (All the questions and answers are written ahead ) I will appreciateit.
Here’s the code that I tried to use but it prints all the lines in the document:
[lua]local path = system.pathForFile( “myfile.txt”, system.ResourceDirectory )
local file, errorString = io.open( path, “r” )
if not file then
print( "File error: " … errorString )
else
for line in file:lines() do
print( line )
end
io.close( file )
end
file = nil
[/lua]