lua-users home
lua-l archive

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


	Hi

...
> _LOADED["foo"] will not be nil. If you then assign nil to 
> _LOADED["foo"], a subsequent require"foo" will run the file again.>> 
> 
> With this in mind, my aim was to do something like 
> _LOADED[funcname] = nil everytime I overwrite the file. 
	Be carefull: you should use the file's name instead of
a function's name.

> My problem is that I'm not able to access this table from my C 
> program, i.e. I do something like 
> lua_getglobal(L, "_LOADED"); 
> if (!lua_istable(L, -1)) 
> {printf"_LOADED is not a valid table"); exit(0);} 
> n = lua_getn(L, -1); n IS ALWAYS ZERO !!!!!! 
	This table should not have an array part, therefore
lua_getn should always return 0.

> lua_getglobal(L, "_LOADED"); 
> if (!lua_istable(L, -1)) 
> {printf"_LOADED is not a valid table"); exit(0);} 
> lua_pushstring(L, funcname); 
> lua_gettable(L, -2); 
> if (!lua_isstring(L, -1)) 
> printf("invalid component in _LOADED"); 
> else 
> myname = lua_tostring(L, -1); 
> lua_pop(L, 1); 
	Note that the value stored in _LOADED["foo"] should be
the value returned by file or `true'.

> I run the require function before so I expected to find something in 
> the _LOADED table. 
> Can anybody please help me to change the _LOADED[] table values from 
> my C program. 
	If your file doesn't return anything, you'll find that
_LOADED[<filename>] == true, and any function defined inside it
should be stored in the global's table.

	Regards,
		Tomás