[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: File I/O, find line?
- From: Joe Seeley <joiey.seeley@...>
- Date: Tue, 11 Jan 2005 16:46:10 -0600
I'm pretty new to Lua, and am using the I/O API for the first time. I
am currently trying to read/write ini files for an application that I
support. The file has parameters similar to this.
[subset1]
param1=foo
param2=foo2
[subset2]
param1=foobar
param2=foobar2
What I would like to do is find if certain parameters are defined for
different subsets. I am able to find my line range by locating the
subset title and then the next blank line following it. I then want
to find my matching parameter that falls inside that range. The way I
would like to do this is with a function like so
FindLineInFile_Range(filename,desired_line,start_of_range,end_of_range)
-- code here....
if line_found then
return line_number
else
return nil
end
end
The problem that I am running into is that the only file offset I have
encountered is a character offset via file:seek("set", charOffset).
Is there an easy way to offset directly to the lines I desire?
Thanks so much in advance!
Joe