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 10-10-2022, 11:01 AM   #421
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
First question: what is a "topmost tag"? It seems that it is the first first hierarchical component of the first tag on the list, but as you can't depend on the order of tags in the list that seems wrong.

What do you want to have happen if the first tag is '[Cleanup]'? Do you want the second tag? if so then this would work:
Code:
	t = sublist($tags, 0, 1, ',');
	if t == "[CLEANUP]" then
		t = sublist($tags, 1, 2, ',')
	fi;
	re(t, '^(.*?)($|\..*$)', '\1')
"Topmost tag" -- if 'Fiction.Mystery.Cozy Mystery', then 'Fiction.' If 'Nonfiction.Biographies & Memoirs', then 'Nonfiction.' I call it that because in the tag browser it appears at the top of the hierarchy.

And yes, just go to the next tag. Hopefully the code works.

Last edited by ownedbycats; 10-10-2022 at 11:33 AM.
ownedbycats is offline   Reply With Quote
Old 10-30-2022, 04:30 PM   #422
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
For a template search, is there a way to search for 'template returns any value'?

e.g. the first search I did via a GPM if-then returning 'yes' but there might be a better way.
ownedbycats is offline   Reply With Quote
Advert
Old 10-30-2022, 04:46 PM   #423
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: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
For a template search, is there a way to search for 'template returns any value'?

e.g. the first search I did via a GPM if-then returning 'yes' but there might be a better way.
Use the "set/not set" match type with "true" or "false" as needed. See the tool tip on the "Template value" box in Advanced search / Template search / Template value.

EDIT: like this (screen capture)
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.png
Views:	68
Size:	27.0 KB
ID:	197469  

Last edited by chaley; 10-30-2022 at 04:52 PM. Reason: Added screen capture
chaley is offline   Reply With Quote
Old 10-30-2022, 06:07 PM   #424
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That works! I should check tooltips more often.
ownedbycats is offline   Reply With Quote
Old 11-23-2022, 04:21 AM   #425
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program: round(days_between($#filedate, $date))
Using this in template search with value '0' also picks up books with an undefined #filedate. How do I avoid this?

EDIT: Also, is there a better way to search that both columns have the same calendar date? MCS failed.

Last edited by ownedbycats; 11-23-2022 at 05:00 AM.
ownedbycats is offline   Reply With Quote
Advert
Old 11-23-2022, 02:28 PM   #426
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: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program: round(days_between($#filedate, $date))
Using this in template search with value '0' also picks up books with an undefined #filedate. How do I avoid this?
None is often equivalent to zero. Try raw_date('#filedate', -1000000).
Quote:
EDIT: Also, is there a better way to search that both columns have the same calendar date? MCS failed.
I would format both dates in the same way, for example yyyy-mm-dd (watch out for mm vs MM -- I never remember which is which), then compare the strings.
chaley is offline   Reply With Quote
Old 11-23-2022, 04:57 PM   #427
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,681
Karma: 26966376
Join Date: Mar 2012
Location: Sydney Australia
Device: none
MM is Month because it's bigger than a minute.

BR
BetterRed is offline   Reply With Quote
Old 11-23-2022, 05:28 PM   #428
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: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
MM is Month because it's bigger than a minute.

BR
chaley is offline   Reply With Quote
Old 11-23-2022, 07:22 PM   #429
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That works. I also could've added #filedate:true to the search.
ownedbycats is offline   Reply With Quote
Old 11-24-2022, 09:27 PM   #430
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:

## Splitting tags
	if 
		'^(Fiction|Nonfiction)' in $#booktype 
	then 
		split_tags = re($tags, '\.', ',') 
	fi;

## Removing a few unwanteds
	cleaned_tags = list_difference(
		split_tags,
		'Fiction, Nonfiction, Cultures & Regions, Social Issues',
		',');
Three things this template to do:
1. Retrieve tags when the booktype is Fiction|Nonfiction.
2. Replace the '.' with a ',' to turn hierarchical tags into a list.
3. Remove a few unwanted entries from the list.

It works... mostly. If booktype is not Fiction|Nonfiction, it returns EXCEPTION: Interpreter: Unknown identifier 'split_tags' - line number 12. What should I do?

EDIT: I found that also adding a second if-then check for Fiction|Nonfiction before cleaning the tags works.

Last edited by ownedbycats; 11-25-2022 at 06:50 AM.
ownedbycats is offline   Reply With Quote
Old 11-25-2022, 09:38 PM   #431
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Is it possible to reference a grouped search in a template?
ownedbycats is offline   Reply With Quote
Old 11-26-2022, 02:43 AM   #432
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: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Is it possible to reference a grouped search in a template?
To do what?
chaley is offline   Reply With Quote
Old 11-27-2022, 12:42 AM   #433
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Something like if 'value' in groupsearch (or inlist?) where groupsearch was a few related columns.

I suppose for this case it might make more sense to just combine them together in the template itself with a list_join or something.
ownedbycats is offline   Reply With Quote
Old 11-27-2022, 02:25 AM   #434
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: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
A different question:

I have this for a column.

Click image for larger version

Name:	2022-11-27 04_23_57-Window.png
Views:	48
Size:	6.8 KB
ID:	198037

Code:
program:
	first_non_empty(
		if 'Cleanup' in virtual_libraries() then 'polish.png' fi,
		if 'Fanfiction' in $#booktype then icons_fanfic() fi,
		if 'Documentations & Manuals' in $#booktype then 'helpbook.png' fi,
		if 'Loans' in virtual_libraries() then 'overdrive.png' fi,
		if 'Physical Books' in virtual_libraries() then 'paperbook.png' fi,
		'view.png',
	)
icons_fanfic() is a strcat that looks like this so that I get multiple icons:

Code:
program:
	f = $#fanficcat;
   strcat(
		if "^Fallout$" inlist f then 'fallout.png:' fi,
		if "^Half-Life$" inlist f then 'halflife.png:' fi,
		if "^(Mass Effect Trilogy|Mass Effect: Andromeda)$" inlist f then 'masseffect.png:' fi,
		if "^The Elder Scrolls$" inlist f then 'theelderscrolls.png:' fi,
		if "^Pokémon$" inlist f then 'pokemon.png:' fi,		
		if "^Portal$" inlist f then 'portal.png:' fi,
   )
In the first template, I'd like to display only the first icon in order to match the others.

If it's possible, it seems the easiest way to do this would be to truncate at the first colon so the output is, e.g. fallout.png instead of fallout.png:halflife.png:. Is this doable?

EDIT: list_split is what i was looking for!

Code:
		if 'Fanfiction' in $#booktype then 
			list_split(icons_fanfic(), ':', 'ff'); 
		ff_0 fi,

Last edited by ownedbycats; 11-27-2022 at 03:46 AM. Reason: fixing indenting
ownedbycats is offline   Reply With Quote
Old 11-27-2022, 12:31 PM   #435
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: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Something like if 'value' in groupsearch (or inlist?) where groupsearch was a few related columns.

I suppose for this case it might make more sense to just combine them together in the template itself with a list_join or something.
A grouped search term (gst) is in effect a way of giving a name to a set of searches, one for each column in the gst. It doesn't have a value outside of a search.

To do what I think you want you need to invoke the search. For example, if you want to know if a gst will match the current book then something like this:
Code:
program:
	globals(ids = '');
	if ! ids then
		ids = book_values('id', '@gst:true', ',', 0);
		set_globals(ids)
	fi;
	$id in ids
The template finds the id of all books matched by the gst and saves it in globals for efficiency. It then checks if the current book id is in the list, returning '1' if so and '' if not.
chaley 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 153 05-14-2024 01:30 AM
[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 08:06 PM.


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