Quote:
Originally Posted by foosion
I'd like to merge some columns I'd created, based on some criteria.
I had been keeping track of the books I've finished by putting a date in #read. Then I got a Kobo and used KoboUtilities to populate #kobopct (the pct of the book I've read on Kobo) and #kobolastread (when I last read the book on Kobo). If #pct = 100, #lastread is when I finished the book.
I'd like to create a new #whenfinished. I think the basic logic would be as follows:
Code:
if #kobopct == 100:
#whenfinished = #kobolastread
else:
#whenfinished = #read [date or blank]
What would be the best way to implement this?
|
"Best" depends on you.
There are two general approaches. The first is to use a "Column built from other columns" (a "composite" column) where the template computes the value you want in the column for the book. The second is to use the Action Chains plugin to compute the column contents on when you ask it to. I'll talk about the first. If you want to know about Action Chains then see that plugin's thread.
Here is a template for a composite column that might do most of what you want.
Code:
program:
if $$#kobopct ==# 100 then
whenfinished = $$#kobolastread
else
whenfinished = $$#read
fi;
whenfinished
For the language syntax look in the
General Program Mode section of the calibre template language documentation. If you are going to ask more questions about this then I suggest you make a separate thread.
You might want to format the dates, in which case you would use the format_date() function after the fi, as in
Code:
whenfinished = format_date(whenfinished, 'whatever format')