lua-users home
lua-l archive

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


Depending on how regular the declarations are, pattern matching seems
easier than messing with syntax:

local file = [[
VARIABLE "MyVar" = "Hello"
VARIABLE "OtherVar"="Goodbye"
]]

for name, value in string.gmatch(file,
"VARIABLE%s*\"([%w_]+)\"%s*=%s*\"([^\"]*)\"") do
    _G[name] = value
end

print(MyVar, OtherVar)

--> Hello	Goodbye

Vaughan