View Single Post
Old 04-05-2018, 03:33 AM   #17
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
The problem you are having is that the definition of the cmp function is:

Code:
cmp(x, y, lt, eq, gt)
The values in the "lt", "eq" and "gt" parameters are return depending on the result of the comparison between "x" and "y". If "x < y", then whatever is in the "lt" position is returned, if "x = y", then "eq" is returned and if "x > y", then "gt" is return. In both of your templates, you are returning a value for the "x > y" case.

That means that the second template returns the icon name if there is two or more fandoms.

And the first template returns the icon name if there are three or more fandoms.

But, if there are three or more fandoms, then the condition in the second template is also met, so it returns the icon as well.

With this, the second template should be:

Code:
program:
cmp(count(field('#fandoms'), '&'), 2, '', 'crossover.png', '')
That will return "crossover.png" if there are exactly 2 fandoms.

But, combining them is probably better:

Code:
program:
cmp(count(field('#fandoms'), '&'), 2, '', 'crossover.png', 'multi.png')
That returns nothing if there is one fandom, "crossover.png" if there are two fandoms and "multi.png" if there are three or more fandoms.


Disclaimer: I haven't tested these templates. They have been written by looking at the manual.
davidfor is offline   Reply With Quote