lua-users home
lua-l archive

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


On 7/4/07, Thomas Harning Jr. <harningt@gmail.com> wrote:
lua.eval might be a command for elinks.

Lua doesn't have such a command.  If you want to execute the contents
of a string, you would do: assert(loadstring(...))()

On 7/4/07, Kelly Jones <kelly.terry.jones@gmail.com> wrote:
> I just installed Lua to script elinks (I recompiled elinks w/ Lua support).
>
> >From the command-line, basic Lua expressions work fine, but I can't
> get any form of eval working:
>
> > lua
> Lua 5.0  Copyright (C) 1994-2003 Tecgraf, PUC-Rio
> > print(5^10)
> 9765625
> > lua.eval("print(5^10)")
> stdin:1: attempt to index global `lua' (a nil value)
> stack traceback:
>         stdin:1: in main chunk
>         [C]: ?
> > eval("print(5^10)")
> stdin:1: attempt to call global `eval' (a nil value)
> stack traceback:
>         stdin:1: in main chunk
>         [C]: ?
>
> >From elinks, if I use "," to get to the Lua console, nothing seems to
> work. I tried "2+2", "print(2+2)", and others, and always get back:
>
> ELinks: Lua: bad argument for eval
>
> I sense I'm doing something fundamentally wrong here and/or my
> installation of Lua is incomplete somehow? Help!
>
> Note: I'm intentionally using Lua 5.0 because Lua 5.1 and up doesn't
> work w/ my version of ELinks (0.11.3) according to the docs.


--
Thomas Harning Jr.


You could do something like
function eval(str)
   return assert(loadstring(str))()
end