LuaScript Xojo and Real Studio Plugin

LuaScriptContext.GetNext Method (console safe)

Used to traverse tables. Returns zero if no next element was found else non zero value

GetNext(
   index as Integer) as Integer

Parameters

index
index into the stack.

Returns

Integer
Zero if no next element was found else non zero value

Remarks

if ls.GetGlobalTable("background") then
    ls.PushNil() // First key
   
    while ls.GetNext(1) <> 0 // Table is at index 1 in the stack
       data = ""
      
       if lua.IsString(-2) then
          data = lua.GetString(-2,false) + ": "
       end if
      
       if lua.IsNumber(-1) then
          data = data + Format(lua.GetDouble(-1,false),"#,##")
       end if
      
       MsgBox data
      
       ls.Pop()
    wend
   
    ls.Pop() // We pop the table off the stack once we are done with it
   
end if

See Also

LuaScriptContext Class