View Single Post
Old 11-16-2021, 09:47 PM   #1
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
Template editor and Date columns

I noticed an error on a metadata plugboad when looking at the details on the device. It was caused by using more than one library and not updating the plugboards across them all. So, I copied the updated plugboard to the new library. When I did this, there was an error shown in the template editor:

Code:
EXCEPTION:  Interpreter: Unknown field '#kobo_last_read' - line number 4
I assumed this meant I had the differences in the column name, but, thought I had kept that synced. But, that wasn't the case. The column "#kobo_last_read" did exist.

Reducing this to the minimum, the template is:

Code:
program:
kobo_last_read_str = test($#kobo_last_read,strcat('<p><b>Last Read:</b> ', $#kobo_last_read, '</p>'),'');
That gives the same error, with the line number 2.

When I connected the device, it worked. The comment was updated with the correct string depending on if there was a value in #kobo_last_read.

After playing with this a bit, it appears that there are problems with date type fields. I have several in the test library and they all gave the error. They usually give the above error. But, there is also a difference between opening the template editor from the metadata plugboard screen and for a custom column. I always get it the error when opened from the metadata plugboard screen, but, not always from the column editor. But, I haven't got a consistent behaviour for that.

Changing the template to use the "field" function didn't change it. But, "raw_field" or using $$#kobo_last_read did. In this case:

Code:
program:
kobo_last_read_str = test(raw_field("#kobo_last_read"),strcat('<p><b>Last Read:</b> ', raw_field("#kobo_last_read"), '</p>'),'');
Produced the result:

Code:
<p><b>Last Read:</b> ('#kobo_last_read',)</p>
Also, using the built-in column "timestamp" has interesting behaviour.

Code:
program:
kobo_last_read_str = test(field("timestamp"),strcat('<p><b>Last Read:</b> ', field("timestamp"), '</p>'),'');
Returns an empty the empty string. Again, this is different for whether the template editor is started from the metadata plugboard screen or the column editor.

This is with calibre 5.32 on Windows 10. I am normally running from source. But, I did check the above against the installed version.
davidfor is offline   Reply With Quote