lua-users home
lua-l archive

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


>i've got a simple and straightforward question regarding the
>implementation of file:read(). is it possible to read two numbers, one
>following the other, with different ranges? like in c, for example,
>assuming a file containing '12345', the code:
>
>        (void)fscanf("%2d", &x);
>        (void)fprintf(stdout, "%d!\n", x);
>        (void)fscanf("%3d", &x);
>        (void)fprintf(stdout, "%d!\n", x);
>
>gets you:
>
>12!
>345!

Try tonumber(file:read(2)) and tonumber(file:read(3))...
--lhf