[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua as Configuration Conditional Statement inside table definition
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 10 Nov 2010 10:10:10 +0200
On Wed, Nov 10, 2010 at 9:45 AM, Gopalakrishnan Subramani
<gopalakrishnan.subramani@gmail.com> wrote:
> Enum1 = ENUMERATION {
> {1, "Forward"},
> {2, "Backword"},
>
> if BIDIERCTIONAL_SUPPORTED then
> {3, "BiDirectional"},
>
> {4, "None" }
> }
>
> If you see, the "Bidirectioanl" is added only if it is enabled. I don't
> think, Lua support statements within the table definition.
That is true, so you can't do it this way. But you could state it like
this by making your enumerations objects:
Enum1 = ENUMERATION()
Enum1:add {1,"Forward"}
Enum1:add{2,"Backward"}
if BIDIERCTIONAL_SUPPORTED then Enum1:add{3,"BiDirectional"} end
Enum1:add {4,"None"}
Which is not so pretty. So how about this?
Enum1 = ENUMERATION {
{1, "Forward",true},
{2, "Backword",true},
{3, "BiDirectional",BIDIERCTIONAL_SUPPORTED},
{4, "None",true}
}
And loop through the enumeration afterwards and remove fields where
the conditional entry is false/nil - this can be done by the
ENUMERATION function directly.
steve d.