lua-users home
lua-l archive

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


Hello,

I'm new in lua. 
What's the usage of globals([table]) ? 
In the example above I try to assign my own globals but this don't work.
I need to set for a time myGlobals and after restore initial globals.
May be I don't do this in a fine way.

Thank's



a = 1
b = 2


function x(l)
  print('x Start')
  local c = 8
  l.f = function(v) 	 print('function f () v = ' .. v)  end
  l.c = c
  l.print = print
  l.dostring = dostring
  l.globals = globals
  l.print("before globals(l)")
  l.savglobals = globals()
  globals(l)
  f(a)

  print("after  globals(l)")
  print('before dostring');
  dostring('print("in dostring"); f(a); f(b); f(c); ')	 
  globals(savglobals)
  print("x end")
end


myGlobals = {}
myGlobals.a = a
myGlobals.b = b
x(myGlobals)
-- 


@+

Jean Claude Morlier
-------------------
Quetzal Informatique
morlier@quetzal.fr
tél  : 0557261110