[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Traverse Stack and Syntax Checking?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 6 Sep 2002 08:10:12 -0300
>How can I go about traversing the LUA stack looking
>for all user defined, global variables (not any
>constants, etc).
for i,v in globals() do ... end
>Secondly, is there any way to do syntax checking
>without having to run the scripts?
>How do I retrieve the errors associated with the script code?
This is a FAQ. In Lua 4.0 you need wrap the code inside
"return function ()... end"
and then run dostring on the wrapped code. If dostring succeeds, then there
was no syntax error and you get the code as a return value that you can run
simply by calling it with (). If there are syntax errors, then dostring
returns nil and an error messages.
In Lua 5.0, you can use loadstring without having to wrap your code. The
rest is the same.
>I am trying to build a view similar to that of Visual
>Studio where all of the global variables are listed,
>then all of the functions, and their associated member
>variables.
What are "associated member variables"?
--lhf