|
|
Evgenij Gagauz wrote:
> Unfortunatly the best way is express it with the something like case statement,
> not with the "select" function.
I just hacked something up which might do what you want,
with the following limitations
1. No nesting of fswitch blocks
2. Quotes required around all subexpressions (except plain numbers)
Basically, it is a set of macros which will write an include
file containing the nested select statements.
#macro fswitch(CONTROL)
#declare CASE_CONTROL = CONTROL;
#declare CASE_COUNTER = 0;
#fopen CASE_FILE "switch_tmp.inc" write
#end
#macro fcase(CASE,VALUE)
#declare CASE_COUNTER = CASE_COUNTER + 1;
#write(CASE_FILE,"select((",CASE_CONTROL,")-(",CASE,"),",VALUE,",\n")
#end
#macro fdefault(VALUE)
#write(CASE_FILE,VALUE)
#while(CASE_COUNTER > 0)
#write(CASE_FILE,")")
#declare CASE_COUNTER = CASE_COUNTER - 1;
#end
#fclose CASE_FILE
#include "switch_tmp.inc"
#end
function(a,b)
{
fswitch("a")
fcase(0.1,"1")
fcase(0.5,"b")
fdefault("0")
}
Post a reply to this message
|
|