Next: , Previous: slua_tbl_nelem, Up: Manipulating Tables


A.2.2 slua_tbl_next

an implementation of the Lua next function

Synopsis

     #include <luasup/luasup.h>
     
     
     
lua_Object slua_tbl_next( lua_Object table, lua_Object *index );

Parameters

lua_Object table
the table to iterate over
lua_Object *index
A pointer to the last index used; set the index's value to LUA_NOOBJECT on the first pass

Description

This routine is a wrapper around the Lua next function, for which there are no default bindings for C. It is passed a table and an index. The index should be set to LUA_NOOBJECT to start the scan in the table. slua_tbl_next will update the index to point to the next element in the table, and will return the value in the table at that index. Note that the address of the index is passed to slua_tbl_next.

If there are no more elements in the table, the returned value and the index are set to LUA_NOOBJECT.

Returns

It returns the value of the table at the next index, or LUA_NOOBJECT if there are no more elements.

Author

Diab Jerius