[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Minimizing repeatable statements with out LuaMacro
- From: Ico <lua@...>
- Date: Mon, 20 Jun 2011 07:27:21 +0200
* On Mon Jun 20 06:54:51 +0200 2011, PROXiCiDE wrote:
> Is it possible to crunch these repeatable statements in Lua? with out the
> rewrite "IF" statements etc.. maybe inside Array/Table checking etc
>
> if(xArg.exp==">") then
> if(what > number) then
> print(name,daysTotal)
> end
> end
>
> if(xArg.exp==">=") then
> if(what >= number) then
> print(name,daysTotal)
> end
> end
>
> if(xArg.exp=="<") then
> if(what < number) then
> print(name,daysTotal)
> end
> end
>
> if(xArg.exp=="<=") then
> if(what <= number) then
> print(name,daysTotal)
> end
> end
>
> if(xArg.exp=="=") then
> if(what == number) then
> print(name,daysTotal)
> end
> end
You could use loadstring() to generate a piece of lua code on the fly to
do the check, something like (untested):
if loadstring('return '.. what .. xArg.exp .. number)() then
print(name,daysTotal)
end
--
:wq
^X^Cy^K^X^C^C^C^C