so I have this huge file with 100.000 entries for a trivia bot, well I decided not to load all of it into memory.
but i also don't want to run through the file again and again, when getting new questions...
so thaught, why not seek through the file on startup, store the seeks in a table and... then get those random seeks, and read from line.
okey, problem is, actually only, that LUA will always set the curser, to the beginning of a line = read(handle) but ptokax won't, any idea why, I get 2 different results when I use ptokax and the other time lua 4.0.
here is my func.
function ReadSeek(QFile)
handle2 = openfile(QFile,"r")
if handle2 then
local line = read(handle2)
while line do
local sek = seek(handle2,"cur")
line = read(handle2)
tinsert(seeks,sek)
end
closefile(handle2)
end
local handle = openfile("testseek.txt","w")
for i = 1,getn(seeks) do
write(handle,seeks[i].."\r\n")
end
closefile(handle)
end
other question.. does a set seek, take as long as a
local line = openfile(blabla)
var = 0
while line do
var = var + 1
if var == XX then
Line to get
end
end
nevermind got it myself :)