lua-users home
lua-l archive

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



On 18-Aug-05, at 11:18 PM, Ron Hudson wrote:



Philippe,

read.io()  gets one line from the current file, or standard input.


Actually, that's io.read() :) I assume you actually got it right in your program.

The following little Lua program works (io.lines is a much easier way of iterating lines of a file, but it's not actually different from the repeat loop):

----> transcript:

rlake@freeb:~$ cat hudson.test
foo
bar
&
glitch
&
comma
&&
ignored
&
rlake@freeb:~$ cat hudson.lua
count = 0
for aline in io.lines() do
  if aline == "&" then count = count + 1
  elseif aline == "&&" then break
  end
end
print(count)

rlake@freeb:~$ lua hudson.lua < hudson.test
2

<------ end of transcript

I believe that's the expected result.

Can't help you more without knowing a lot more details.