lua-users home
lua-l archive

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


Javier Guerra wrote:
On Thursday 20 April 2006 4:12 pm, Kristopher Lohmuller wrote:
Thanks. For some reason 5.0 accepts the (not disp and not next(disp)),
but it still doesn't like the alternatives in the for statement.
Recognizes that they are valid calls, but still says it is expecting a
table value for disp but that disp is nil. Odd thing is that it gives
this error even if the table has a value.

that sounds like you're not giving it the right table. double check for typos and scope. maybe you're setting a local 'disp' and accessing a global 'disp' or something like that

remember, if you try to access a nonexistant variable, it won't give you any error, just return a nil value. (and fail somewhere else because of that nil value)


What is going on is that disp is a local variable that is assigned the value of a global variable. The global is a blank table normally, but values can be saved in it. What makes me scratch my head is that if there is a value in the global table, I still get the error. What makes me scratch my head even more is that even with that error, the for statement still proceeds normally and correctly.