lua-users home
lua-l archive

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


What Sam said and:

On Mon, Mar 22, 2010 at 4:07 PM, Tim Channon <tc@gpsl.net> wrote:
> On investigation
>
> print(f:read("*n")  40
> print(f:read("*n")  nil
> print(f:read("*l")  astring
>
> What is going on?
>

The second call to f:read("*n") skips all the whitespace "\r\n" (moves
the file position) trying to find a number to read. It fails because
"astring" is not a number. Thus, the next time you read a line you get
"astring".

-- 
- Patrick Donnelly