|
|
You're ---- thinking about #switch and #case() in an --- odd way.
I see where it's going wrong, and this will give you an idea of why:
#switch(true)
#case(1)
rgb <0, 0, 0.2>
#break
#case(
// no (strcmp(IMG_TYPE,AA), which is the only 'correct' match
(strcmp(IMG_TYPE,BB))
| (strcmp(IMG_TYPE,CC))
)
#switch(true) is a very strange usage, and I'm sure clipka could give some
source-code explanation of why it works the way it does.
But basically, as I suspected, it just selects the FIRST #case() regardless of
what it is.
In fact, check out:
#switch(strcmp(IMG_TYPE,BB) | strcmp(IMG_TYPE,CC) )
#case(-10)
rgb <1, 1, 0>
#break
#case(-6)
rgb <1, 1, 1>
#break
#case(1)
rgb <0, 0, 0.2>
#break
#case(1000)
It selects the blue pigment, which corresponds to 1.
So, I think you need to do something along the lines of
#declare IMG_TYPE = (some string operator on your filename)
#if IMG_TYPE = "jpg" #local AA = 1; #end
#if IMG_TYPE = "png" #local AA = 2; #end
#if IMG_TYPE = "tiff" #local AA = 3; #end
#select (AA)
.....
OR, since if any one of the cases you want to select for is going to yield a
value of zero for strcmp(),
#declare Pig = strcmp(IMG_TYPE,AA) * strcmp(IMG_TYPE,BB) * strcmp(IMG_TYPE,CC);
and then #select (Pig)
(that works for me)
Post a reply to this message
|
|