lua-users home
lua-l archive

Re: reset table - sorry again a bug

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Learning by doing... Non working example!
 local Lines={}
 repeat
 local Line=Handle:read('*line') --> bug local Line
 Line=Line and string.gsub(Line,'\r','')
 if Line==nil or Line=='' then
-- process lines here; e.g. with iterator
 Lines={}
 else
 table.insert(Lines,Line)
 end
 until Line==nil --> Line is ever nil
> Jamie Webb wrote:
> In fact, as written, it won't work at all. The declaration of Lines
> needs to be moved outside the loop.
And in my newer example also the declaration of Line needs to be moved
outside the loop. After all the working example:
 local Lines,Line = {}
 repeat
 Line=Handle:read('*line')
 Line=Line and string.gsub(Line,'\r','')
 if Line==nil or Line=='' then
-- process lines here; e.g. with iterator
 Lines={}
 else
 table.insert(Lines,Line)
 end
 until Line==nil
I am a programmer since ~20years now but sometimes I fall back to a
newbie ;-)
--
Markus

AltStyle によって変換されたページ (->オリジナル) /