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 12-27-2021, 05:01 PM   #256
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
The #genres columns - main thing is if I switch between, say Fanfiction and Read/Unread too quickly, they start displaying the wrong entries for that VL (combined or only cleaned_tags) -- I'm guessing something to do with the caching, because re-saving the template recalculates them all. F5 doesn't fix this, nor does re-searching.
Does selecting all books, doing a bulk edit metadata, changing nothing, then pressing OK fix it? If so then the problem could be related to the GUI caches. I have no idea what view manager does, but it probably should do IIRC a
Code:
gui.current_db().refresh()
EDIT: Don't know whether action chains does anything special.

EDIT2: you might need to check the "Refresh book list after edit" in the bulk dialog for 'correction' to work.

Last edited by chaley; 12-27-2021 at 05:04 PM.
chaley is offline   Reply With Quote
Old 12-27-2021, 05:22 PM   #257
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Yes, the bulk metadata edit fixes it.

I tried making this custom AC module, but it gave me an error:

Code:
from calibre_plugins.action_chains.actions.base import ChainAction

class RefreshAction(ChainAction):

    name = 'Refresh GUI'

    def run(self, gui, settings, chain):
        gui.current_db().refresh()
ownedbycats is offline   Reply With Quote
Advert
Old 12-27-2021, 05:29 PM   #258
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Yes, the bulk metadata edit fixes it.

I tried making this custom AC module, but it gave me an error:

Code:
from calibre_plugins.action_chains.actions.base import ChainAction

class RefreshAction(ChainAction):

    name = 'Refresh GUI'

    def run(self, gui, settings, chain):
        gui.current_db().refresh()
Looking at calibre's code I think it should be
Code:
gui.current_db().data.refresh()
Alternatively, try
Code:
gui.refresh_all()
From what I see this method refreshes all the various bits of calibre including the tag browser, the database, and the gui. It also does a resort.
chaley is offline   Reply With Quote
Old 12-27-2021, 08:10 PM   #259
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Hmm, data.refresh gave me the same error:

Code:
calibre, version 5.34.0
ERROR: Unhandled exception: <b>TypeError</b>:'LibraryDatabase' object is not callable

calibre 5.34 [64bit]  embedded-python: True is64bit: True
Windows-10-10.0.19041 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19041')
Python 3.8.5
Windows: ('10', '10.0.19041', '', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeACSM (0, 0, 15) && DeDRM (7, 2, 1) && Action Chains (1, 14, 0) && Barnes & Noble (1, 2, 16) && Calibre Power Search Plugin (2, 1, 1) && Comments Cleaner (1, 5, 0) && Count Pages (1, 11, 1) && Embed Comic Metadata (1, 6, 1) && EpubCheck (0, 2, 3) && EpubMerge (2, 11, 0) && Extract ISBN (1, 5, 0) && FanFicFare (4, 8, 4) && Fantastic Fiction (1, 5, 0) && Favourites Menu (1, 0, 5) && Find Duplicates (1, 8, 10) && Generate Cover (2, 0, 2) && GetFileName (0, 1, 1) && Goodreads (1, 5, 1) && Import List (1, 5, 6) && Job Spy (1, 0, 190) && Kindle hi-res covers (0, 5, 0) && Kobo Books (1, 8, 3) && Kobo Utilities (2, 14, 1) && KoboTouchExtended (3, 5, 4) && Last Modified (0, 7, 1) && Library Codes (1, 0, 50) && Manage Series (1, 2, 11) && Modify ePub (1, 6, 3) && MultiColumnSearch (1, 0, 87) && Obok DeDRM (7, 2, 1) && Open With (1, 5, 13) && Overdrive Link (2, 49, 0) && Quality Check (1, 11, 4) && Reading List (1, 7, 7) && Search The Internet (1, 8, 1) && SmartEject (2, 3, 0) && Standard Ebooks (1, 0, 0) && Sum Column (0, 3, 1) && View Manager (1, 6, 1) && Walk Search History (1, 3, 2) && Overdrive Link* (2, 49, 0)
Traceback (most recent call last):
  File "calibre_plugins.action_chains.action", line 454, in run_chain
  File "calibre_plugins.action_chains.chains", line 396, in run
  File "calibre_plugins.action_chains.chains", line 211, in _run_loop
  File "calibre_plugins.action_chains.chains", line 188, in _run_loop
  File "Refresh GUI", line 8, in run
TypeError: 'LibraryDatabase' object is not callable
refresh_all doesn't error, but it didn't refresh the column (it does resort books though)
ownedbycats is offline   Reply With Quote
Old 12-27-2021, 08:19 PM   #260
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Also, unrelated to the above error:

Is it possible to put a strcat inside a first_non_empty? For icon_fanfics shared template, I want to display multiple icons, but if none exist then use a placeholder. This gave me an error:

Code:
program:

first_non_empty(
   strcat
   (
		if "^foo$" inlist $#taglike then 'foo.png:' fi,		
		if "^bar$" inlist $#taglike then 'bar.png:' fi,
		if "^foobar$" inlist $#taglike then 'foobar.png:' fi,
   )
   if $#taglike then 'placeholder.png' fi 
)
I considered a list_difference (I use one for icons_formats) but I have close to 50 entries!

EDIT: I found a very weird workaround that maybe only works because it's a shared template. I put this in column rules/emblems:

Code:
program:

		if icons_fanfic() then icons_fanfic() 
		else 'placeholder.png' fi

Last edited by ownedbycats; 12-27-2021 at 08:36 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 12-28-2021, 05:22 AM   #261
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Hmm, data.refresh gave me the same error:

Code:
calibre, version 5.34.0
ERROR: Unhandled exception: <b>TypeError</b>:'LibraryDatabase' object is not callable

calibre 5.34 [64bit]  embedded-python: True is64bit: True
Windows-10-10.0.19041 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19041')
Python 3.8.5
Windows: ('10', '10.0.19041', '', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeACSM (0, 0, 15) && DeDRM (7, 2, 1) && Action Chains (1, 14, 0) && Barnes & Noble (1, 2, 16) && Calibre Power Search Plugin (2, 1, 1) && Comments Cleaner (1, 5, 0) && Count Pages (1, 11, 1) && Embed Comic Metadata (1, 6, 1) && EpubCheck (0, 2, 3) && EpubMerge (2, 11, 0) && Extract ISBN (1, 5, 0) && FanFicFare (4, 8, 4) && Fantastic Fiction (1, 5, 0) && Favourites Menu (1, 0, 5) && Find Duplicates (1, 8, 10) && Generate Cover (2, 0, 2) && GetFileName (0, 1, 1) && Goodreads (1, 5, 1) && Import List (1, 5, 6) && Job Spy (1, 0, 190) && Kindle hi-res covers (0, 5, 0) && Kobo Books (1, 8, 3) && Kobo Utilities (2, 14, 1) && KoboTouchExtended (3, 5, 4) && Last Modified (0, 7, 1) && Library Codes (1, 0, 50) && Manage Series (1, 2, 11) && Modify ePub (1, 6, 3) && MultiColumnSearch (1, 0, 87) && Obok DeDRM (7, 2, 1) && Open With (1, 5, 13) && Overdrive Link (2, 49, 0) && Quality Check (1, 11, 4) && Reading List (1, 7, 7) && Search The Internet (1, 8, 1) && SmartEject (2, 3, 0) && Standard Ebooks (1, 0, 0) && Sum Column (0, 3, 1) && View Manager (1, 6, 1) && Walk Search History (1, 3, 2) && Overdrive Link* (2, 49, 0)
Traceback (most recent call last):
  File "calibre_plugins.action_chains.action", line 454, in run_chain
  File "calibre_plugins.action_chains.chains", line 396, in run
  File "calibre_plugins.action_chains.chains", line 211, in _run_loop
  File "calibre_plugins.action_chains.chains", line 188, in _run_loop
  File "Refresh GUI", line 8, in run
TypeError: 'LibraryDatabase' object is not callable
refresh_all doesn't error, but it didn't refresh the column (it does resort books though)
Darn. It should be
Code:
gui.current_db.data.refresh()
I looked at refresh_all() again. It doesn't clear the caches. data.refresh() does.

Last edited by chaley; 12-28-2021 at 05:26 AM.
chaley is offline   Reply With Quote
Old 12-28-2021, 05:26 AM   #262
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Also, unrelated to the above error:

Is it possible to put a strcat inside a first_non_empty? For icon_fanfics shared template, I want to display multiple icons, but if none exist then use a placeholder. This gave me an error:

Code:
program:

first_non_empty(
   strcat
   (
		if "^foo$" inlist $#taglike then 'foo.png:' fi,		
		if "^bar$" inlist $#taglike then 'bar.png:' fi,
		if "^foobar$" inlist $#taglike then 'foobar.png:' fi,
   )
   if $#taglike then 'placeholder.png' fi 
)
I considered a list_difference (I use one for icons_formats) but I have close to 50 entries!

EDIT: I found a very weird workaround that maybe only works because it's a shared template. I put this in column rules/emblems:

Code:
program:

		if icons_fanfic() then icons_fanfic() 
		else 'placeholder.png' fi
Yes, you can use strcat in a first_non_empty. However, you need to be careful about where you put commas. Your template should be
Code:
program:

first_non_empty(
   strcat
   (
		if "^foo$" inlist $#taglike then 'foo.png:' fi,		
		if "^bar$" inlist $#taglike then 'bar.png:' fi,
		if "^foobar$" inlist $#taglike then 'foobar.png:' fi
   ),
   if $#taglike then 'placeholder.png' fi 
)
I removed the comma at the end of line 6 (the foobar line) and added one on line 7 (the ')' line).
chaley is offline   Reply With Quote
Old 12-28-2021, 12:53 PM   #263
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
gui.current_db.data.refresh() worked - made the sorting go weird, so instead of attaching it to the tab-switch chain itself I instead made a chain (bound to Ctrl+F5) that runs the module and then re-applies the view/sort.
ownedbycats is offline   Reply With Quote
Old 12-28-2021, 04:25 PM   #264
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
gui.current_db.data.refresh() worked - made the sorting go weird, so instead of attaching it to the tab-switch chain itself I instead made a chain (bound to Ctrl+F5) that runs the module and then re-applies the view/sort.
There are methods to redo the sort and search. I am not at my computer to check but IIRC you call them with
gui.library_view.model().resort()
and
gui.library_view.model().research()
chaley is offline   Reply With Quote
Old 12-28-2021, 04:46 PM   #265
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
from calibre_plugins.action_chains.actions.base import ChainAction

class RefreshAction(ChainAction):

    name = 'Refresh GUI'

    def run(self, gui, settings, chain):
        gui.current_db.data.refresh()
        gui.library_view.model().resort()
This works!
ownedbycats is offline   Reply With Quote
Old 12-29-2021, 02:08 PM   #266
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
from calibre_plugins.action_chains.actions.base import ChainAction

class RefreshAction(ChainAction):

    name = 'Refresh GUI'

    def run(self, gui, settings, chain):
        gui.current_db.data.refresh()
        gui.library_view.model().resort()
This works!
Good. As I think you surmised the problem is happening because in your library the value of a composite column can change depending which virtual library is selected. I suspect that you are the only calibre user that does that. Virtual libraries are internally treated as searches, and calibre expects that a search can't change the value of a field. Unfortunately in your case that expectation is wrong.
chaley is offline   Reply With Quote
Old 12-29-2021, 04:51 PM   #267
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
current_virtual_library_name() is a relatively new function, so I'm possibly the first person to even think of it. Mostly just to see it I could - I already use the function to display/hide icons based on the current VL, so why not column values? Creating the read/unread VLs was a good opportunity to experiment.

I did some across an oddity though. The book list view is sorted, but not in book details.

Click image for larger version

Name:	2021-12-29 17_58_51-calibre — __ My Books __ Read __.png
Views:	662
Size:	268.0 KB
ID:	191090

Not a big issue, but curious as to what's going on seeing as there's no sorting going on in the template.

Last edited by ownedbycats; 12-29-2021 at 06:54 PM.
ownedbycats is offline   Reply With Quote
Old 12-31-2021, 04:01 PM   #268
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quick question: Are there any instances where field('column') and $column (or raw_field and $$column) are not interchangeable?
ownedbycats is offline   Reply With Quote
Old 12-31-2021, 04:07 PM   #269
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Quick question: Are there any instances where field('column') and $column (or raw_field and $$column) are not interchangeable?
Only one that I know of and that doesn't strictly conform to your question -- when the field name is itself variable. For example, the expression:
Code:
x = field(substr($a, 1, 10))
cannot be expressed in $ notation.
chaley is offline   Reply With Quote
Old 01-06-2022, 09:39 PM   #270
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,012
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Is it possible to set variables outside of the stored template?

Context: I am making this template meant for use in the column colouring.

Code:
program:

## date = $#datecol;
now = format_date(today(), 'yyyy-MM-dd');

		if days_between(date, now) <= '1' then '#aaaaa'
		elif days_between(date, now) <= '3' then '#bbbbb'
		elif days_between(date, now) <= '7' then '#ccccc' 
		fi
(though it's not quite working as expected - getting #aaaa for everything )

Note that the date variable is commented out -- I tried saving it as a stored template, colours_days_between. then this in the template tester:

Code:
program:
date = $#fanficupdated;

	colours_daysbetween()
It told me 'date' wasn't found.

I noticed this

Quote:
template(x) – evaluates x as a template. The evaluation is done in its own context, meaning that variables are not shared between the caller and the template evaluation.
so I'm thinking I'm doing this wrong but I'm not sure how to pass variables to the template - I noticed eval, but not sure if that's right.

Last edited by ownedbycats; 01-06-2022 at 10:27 PM.
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 218 07-11-2025 07:34 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 02:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 11:37 AM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 09:19 PM
Thread management questions meme Feedback 6 01-31-2011 05:07 PM


All times are GMT -4. The time now is 05:09 AM.


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