lua-users home
lua-l archive

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


I don't think that's the problem, MyVar is simply an identifier that can be used to look up whatever. The problem is it's failing the parsing stage, so it won't work regardless of what VARIABLE returns. I don't think you can do it without stripping the = token:

  function VARIABLE(handler)
      return function(value)
          _G[handler] = value
      end
  end

VARIABLE "MyVar" "Hello"
print(MyVar)        --> Hello

Mark Feldman

HyperHacker wrote:
I can't see how that would work. You're assigning "Hello" to either a
string or a function call; neither are valid.

On Tue, Apr 27, 2010 at 20:55, Joshua Jensen <jjensen@workspacewhiz.com> wrote:
There is a configuration file I deal with that has a syntax like so:

VARIABLE "MyVar" = "Hello"

I thought that, perhaps, Lua could read it directly.  Having a function
called VARIABLE that works with Lua's simplified single parameter string
syntax will solve the VARIABLE "MyVar" portion:

function VARIABLE(name)
   --
end

At this point, I am uncertain what I would have VARIABLE() return that would
allow me to pick up the right side (= "Hello") of the configuration line.

Any thoughts?  Is it possible?

Thanks.

Josh






This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.