View Single Post
Old 04-16-2011, 02:07 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by rwelbourn View Post
Thanks for the reply. I was able to get what I needed thanks to your advice but I used a dirtier method initially.

{author:contains({title}, true, false)}

With some perseverence I got to what you intended (I think):

{:'strcmp("{author}", "{title}", 'false', 'true', 'false')'}

This worked really well but tripped up if there were any " in the title - any way around this? not that it really matters - just curious.

Many thanks for your valuable guidance - didn't even know about templates - glad I do now!!
I have no idea why that template works. It shouldn't. Sub-templates are not (supposed to be) supported. Some day I will look at it. There are probably some bugs lurking there somewhere.

What you should use to get the author and title values is the field function. The complete template would be
Code:
{:'strcmp(field('author'), field('title'), 'false', 'true', 'false')'}
An alternate form in general program mode, slightly faster because it avoids the outermost template parsing, is
Code:
program: strcmp(field('author'), field('title'), 'false', 'true', 'false')
chaley is offline   Reply With Quote