i want to read random line from the multiline file, because i want to search some data in line
how can i do for that ?(
--openfile in read mode
local handle = openfile(file,"r")
--read one line
local line = read(handle)
--see if line is there
while line do
--your stuff to do with line
--read next line
line = read(handle)
end
--closefilehandle
closefile(handle)
thx a lot
i know this method
i mean like this
i have 10 lines
i think only of to read the 6th
can u hlp me
as always there are many ways...
but I think the simplest way would be you create a
variable
at the first line = read(handle)
set the varaible to zero
(ex: var = 0)
and then always count one up each while
var = var + 1
then check if var is your search line
if var == 6 then
--do what you want with line 6
break
end
I would call that break cause you don't wanna read any futher.
other soltuion is bit more advanced but faster.
you need to seek all line beginnings once, and insert those seeks in a table, then you have your line positions and call them by seek again.
That what I use in my still now small trivia bot... but that way I have fast access to many lines, and don't have load all questions in a table :). Might post a preview later.
thx a lot
u have resolved my big problem
i try to seek all lines in a table but always
Syntax Error and tell me attempt to concat a nil value
so i don't konw and should how do