[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua as Configuration Conditional Statement inside table definition
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 10 Nov 2010 08:14:30 -0200
> Enum1 = ENUMERATION {
> {1, "Forward"},
> {2, "Backword"},
>
> if BIDIERCTIONAL_SUPPORTED then
> {3, "BiDirectional"},
>
> {4, "None" }
> }
Not pretty but it can be done like this:
Enum1 = ENUMERATION {
[1]={1, "Forward"},
[2]={2, "Backword"},
[(not not BIDIERCTIONAL_SUPPORTED) and 3]={3, "BiDirectional"},
[4]={4, "None" }
}
which will leave an entry with a false key of BIDIERCTIONAL_SUPPORTED is
nil or false. Just ignore it. :-)
If you can change the syntax, then this is much better
Enum1 = ENUMERATION {
Forward=1,
Backword=2,
BiDirectional= BIDIERCTIONAL_SUPPORTED and 3 or nil
None=4,
}