lua-users home
lua-l archive

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

Would it be good enough to copy lua50.exe's functionality that if you
start a command with an equals sign it removes it and puts
"print("...")" around the rest of the line before executing it?

On 7/19/07, Imre Tuske <> wrote:

What I'm trying to achieve is an interactive Lua command line in my
program, which executes the given Lua commands, then display their
results. (Or, let's say, display the result of the first or last
command, if there are more than one.)

According to the lua_pcall() docs, there should be values on the stack
after execution. I noticed that if I specify a "return" statement
explicitly at the end, the values are passed through the stack, but
otherwise not.

What I'd really like is to get results on the stack without giving an
explicit "return" statement. I need it because this will be an
interactive Lua 'console', where users can type quick commands that
get evaluated, and the idea is that the user should type only like


instead of typing

print(math.sin(1)) or
return math.sin(1)

Any ideas on how to achieve this? (An alternative: if I somehow could
detect whether the to-be-executed block contains a single command, and
insert a 'return' statement before it somehow.) I'm open to any idea


[ Imre Tuske | http://... | ]