PtokaX forum

Development Section => Your Developing Problems => Topic started by: st0ne-db on 24 October, 2005, 18:31:25

Title: return a table
Post by: st0ne-db on 24 October, 2005, 18:31:25
i am trying to return a table from a function.
for example..

function test(user)
  local uVars = {}
uVars = getVars();
  gData.."\t"..uVars.var1.."\r\n"
return gData;
end

function getVars()
local var = {
var1 = "value",
}
return var;
end

when i try to access the returned value, i get the error:

attempt to concatenate field `var1' (a nil value)

what am i doing wrong?  tia  

-st0ne-db-
Title:
Post by: bastya_elvtars on 24 October, 2005, 18:35:18
function test(user)
  local uVars = getVars();
  gData.."\t"..uVars.var1.."\r\n" -- wtf is this???
  return gData;
end

function getVars()
  local var = {
    var1 = "value",
  }
  return var
end
Title:
Post by: st0ne-db on 24 October, 2005, 18:39:10
QuoteOriginally posted by bastya_elvtars
function test(user)
  local uVars = getVars();
  gData = uVars.var1
  return gData;
end

function getVars()
  local var = {
    var1 = "value",
  }
  return var
end

im not trying to run this code... im just trying to describe what i want to do. sorry if this is a confusing example.  ?(
Title:
Post by: bastya_elvtars on 24 October, 2005, 18:49:07
local uVars = getVars();

Just shortened... :)
Title:
Post by: st0ne-db on 25 October, 2005, 04:13:33
thx, is working perfectly now :)