Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
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
Old 11-17-2021, 05:45 AM   #2
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
To be sure I understand, the problem exists when you open the template editor from the plugboards dialog? If so then it happens because that dialog doesn't have a book from which to get metadata. It compensates for this by creating a fake book from field metadata, setting each column value to the column name. This fails for non-text fields like date.

I submitted a fix that sets column type-correct values for the made-up book. It is in source now.
chaley is offline   Reply With Quote
Advert
Old 11-17-2021, 06:47 AM   #3
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
That's pretty much it. And would explain what I saw. And it has fixed my test case.

I did get something strange when opening the template editor by pressing F2 on the column in the list. Or maybe from the column editor. But, I can't work out the combination and can't reproduce it now. It was probably user error.
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Template: sum of multiple integers from other columns Quuzuu Library Management 4 01-17-2021 04:35 PM
Showing template-computed columns as [rating] stars isn't possible? kaoruAngel Library Management 2 11-06-2017 08:49 AM
Need help in Custom Columns, template syntax, and rounding numbers dennocoil Calibre 0 07-10-2017 03:24 PM
Request: template-making assistance for column built from other columns iienderii Library Management 9 04-04-2016 10:27 PM
Template editor Jellby Calibre 4 08-23-2014 03:10 AM


All times are GMT -4. The time now is 06:32 AM.


MobileRead.com is a privately owned, operated and funded community.