lua-users home
lua-l archive

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


Ron Hudson wrote:
I am reading through a file that has variable length records, records are separated
with a line containing only the "&". The last line in the file has "&&".

repeat
     aline = read.io()
     if aline == "&" then
       count = count + 1
     end
until aline == "&&"

Neither "&" or "&&" are ever detected.
I have checked the file... & and && are the only thing in the line.
I also have ">" .. aline .. "<" printed and see >&<

I don't know what your read.io function is, but I hope it really returns only one line per call... Now, perhaps you should also check if the line includes the end-of-line character(s) (\n, \r or \r\n). If that's the case, trim them off with a gsub.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --