[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua as Configuration Conditional Statement inside table definition
- From: Philippe Lhoste <PhiLho@...>
- Date: Wed, 10 Nov 2010 14:25:20 +0100
I did something like that in the past: I had a data file, but some cases were complex, so
I put a function there to solve the case.
["argenteuil"] =
{
ru = { liasse = "25", voie = "rue du Pont d'Argenteuil" },
av1 = { liasse = "637", voie = "av. d'Argenteuil" },
av2 = { liasse = "0000", voie = "av. du Vx Ch. d'Argenteuil" },
special =
function(voie)
local f = string.find(string.lower(voie), "rue")
if f ~= nil then
return "ru"
else
-- Avenue
f = string.find(string.lower(voie), "ch")
if f == nil then
return "av1"
else
return "av2"
end
end
end
},
Then we can check if the type of a field is a function, and if so, call it to get the value.
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --