lua-users home
lua-l archive

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


On Thu, Jul 29, 1999 at 01:21:43AM -0300, Pablo Saldo wrote:
> I don't it woul resolve my problem, 'cause I can get the first index
> (calling next(VarName, nil)) outside the loop, but inside this,
> next(VarName, IndexName) still give me the same index, looping forever.

I've run into some problems like this before when I was doing lots of
stuff inthe middle. Remember that the lua2C stack gets blown during
certain operations. I've found that almost everyplace I use "next"
from C, I end up making a lua_ref, doing some work, and then
dereferencing the lua_ref. Here is some psudo-code:

this_index = next(varname,nil);
this_index_ref = lua_ref(this_index);
while (there_are_more_values) {
  /* do some stuff with this_index */


  /* get next */
  this_index = next(varname,lua_getref(this_index_ref))
  this_index_ref = lua_ref(this_index)
}




-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net