Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 04-21-2021, 11:49 AM   #76
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,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I submitted a PR with the changes to
  • remove the newline() function
  • add the character('name') function as an official function
  • document the function
  • display the special characters as escape sequences in the template editor/debugger.
  • make the 'strip()' changes discussed above. This change applies only to GPM templates.
It is in source.

I implemented 'newline', 'tab', 'return', and 'backslash'. 'quote' and 'double_quote' aren't needed, and I decided to wait on 'backspace'.
chaley is offline   Reply With Quote
Old 04-21-2021, 12:29 PM   #77
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,128
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
I tested with all three characters and it is working as expected. Thanks again.
capink is offline   Reply With Quote
Advert
Old 04-21-2021, 02:50 PM   #78
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
@capink Thanks for making use of my thread, I was starting to get worried I was the only one with questions
ownedbycats is offline   Reply With Quote
Old 04-21-2021, 03:04 PM   #79
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,128
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
I've had questions and requests in the past. I used the Action Chains and other threads before this thread was created.
capink is offline   Reply With Quote
Old 04-28-2021, 10:34 PM   #80
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
k = field('#kobocoll');
if check_yes_no('#onkobo', 0, 1, 0) then 'sync.png' 
elif check_yes_no('#onkobo', 0, 0, 1) then
	if list_contains(k, ',', '^[Kobo Store]$', '1', '') then 'drm-locked.png'
	elif list_contains(k, ',', '^[Send to Device]$', '1', '') then 'sync.png'			
	else 'reader.png'
	fi
fi
For line 5 and 6, the presence of the square brackets makes the if statements not work and return reader.png instead. How do I fix that?

Last edited by ownedbycats; 04-28-2021 at 10:39 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 04-28-2021, 10:48 PM   #81
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,906
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
k = field('#kobocoll');
if check_yes_no('#onkobo', 0, 1, 0) then 'sync.png' 
elif check_yes_no('#onkobo', 0, 0, 1) then
	if list_contains(k, ',', '^[Kobo Store]$', '1', '') then 'drm-locked.png'
	elif list_contains(k, ',', '^[Send to Device]$', '1', '') then 'sync.png'			
	else 'reader.png'
	fi
fi
For line 5 and 6, the presence of the square brackets makes the if statements not work and return reader.png instead. How do I fix that?
I assume that is a regex. If so, you will need to escape the square brackets. Add a backslash in before them.
davidfor is offline   Reply With Quote
Old 04-28-2021, 11:17 PM   #82
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,128
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by davidfor View Post
I assume that is a regex. If so, you will need to escape the square brackets. Add a backslash in before them.
As @davidfor pointed out, you should escape the brackets. Also the new inlist keyword can be used instead of list_contains() function:

Code:
program:
    k = field('#kobocoll');
    if check_yes_no('#onkobo', 0, 1, 0) then 'sync.png' 
    elif check_yes_no('#onkobo', 0, 0, 1) then
	    if '^\[Kobo Store\]$' inlist k then 'drm-locked.png'
	    elif '^\[Send to Device\]$' inlist k then 'sync.png'			
	    else 'reader.png'
	    fi
    fi
capink is offline   Reply With Quote
Old 04-28-2021, 11:40 PM   #83
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
thank you
ownedbycats is offline   Reply With Quote
Old 04-29-2021, 04:58 AM   #84
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
	g = field('#genres');
	k = field('#kobocoll');

	if list_contains(g, ',', '^Fanfiction$', '1', '') then
		k = list_union(k, 'Fanfiction', ',')
	fi;

	if list_contains(g, ',', '^Cozy Mystery$', '1', '') then
		k = list_union(k, 'Cozy Mysteries', ',')
	fi;

	if list_contains(g, ',', '^(Fantasy|Science Fiction)$', '1', '') then
		k = list_union(k, 'Fantasy & Sci-Fi', ',')
	fi;

	k
How would I run the first match it finds? For example, if I have a book with "Cozy Mystery" and "Fantasy" in g, I only want it to add Cozy Mysteries.

ownedbycats is offline   Reply With Quote
Old 04-29-2021, 06:02 AM   #85
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,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
	g = field('#genres');
	k = field('#kobocoll');

	if list_contains(g, ',', '^Fanfiction$', '1', '') then
		k = list_union(k, 'Fanfiction', ',')
	fi;

	if list_contains(g, ',', '^Cozy Mystery$', '1', '') then
		k = list_union(k, 'Cozy Mysteries', ',')
	fi;

	if list_contains(g, ',', '^(Fantasy|Science Fiction)$', '1', '') then
		k = list_union(k, 'Fantasy & Sci-Fi', ',')
	fi;

	k
How would I run the first match it finds? For example, if I have a book with "Cozy Mystery" and "Fantasy" in g, I only want it to add Cozy Mysteries.

Use 'elif' (else if) instead of 'if'. Assuming all three are mutually exclusive and in priority order, then this:
Code:
program:
	g = field('#genres');
	k = field('#kobocoll');

	if list_contains(g, ',', '^Fanfiction$', '1', '') then
		k = list_union(k, 'Fanfiction', ',')
	elif list_contains(g, ',', '^Cozy Mystery$', '1', '') then
		k = list_union(k, 'Cozy Mysteries', ',')
	elif list_contains(g, ',', '^(Fantasy|Science Fiction)$', '1', '') then
		k = list_union(k, 'Fantasy & Sci-Fi', ',')
	fi;

	k
EDIT: If the sequence of choices is long then the first_non_empty() function may be more appropriate than a sequence of ifs. As in:
Code:
program:
	g = field('#genres');
	k = field('#kobocoll');

	v = first_non_empty(
		list_contains(g, ',', '^Fanfiction$', 'Fanfiction', ''),
		list_contains(g, ',', '^Cozy Mystery$', 'Cozy Mysteries', ''),
		list_contains(g, ',', '^(Fantasy|Science Fiction)$', 'Fantasy & Sci-Fi', '')
	);

	list_union(k, v, ',')

Last edited by chaley; 04-29-2021 at 06:08 AM.
chaley is offline   Reply With Quote
Old 04-29-2021, 06:44 PM   #86
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you list_union would probably be more appropriate as #genres has a lot of entries.
ownedbycats is offline   Reply With Quote
Old 04-29-2021, 06:59 PM   #87
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
What would be the best way to turn my "Missing Kobo Collection" saved search into a icon for column templates?

Code:
#onkobo:true 
AND (
	#fanficcat:true 
	OR #genres:"=Fantasy" 
	OR #genres:"=Science Fiction" 
	OR #genres:"=Cozy Mystery" 
)

AND (
	#kobocoll:false 
	OR (#kobocoll:"=[Send to Device]" AND #kobocoll:#=1)
	OR (#kobocoll:"=[Kobo Store]" AND #kobocoll:#=1)
)
(btw, thanks for implementing multi-line saved searches. It's helpful )

Last edited by ownedbycats; 04-29-2021 at 10:40 PM.
ownedbycats is offline   Reply With Quote
Old 04-30-2021, 04:31 AM   #88
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,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Thank you list_union would probably be more appropriate as #genres has a lot of entries.
All of my examples used list_union().
chaley is offline   Reply With Quote
Old 04-30-2021, 04:38 AM   #89
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,968
Karma: 62040409
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
oops, I meant first_non_empty. parkie brain strikes again...
ownedbycats is offline   Reply With Quote
Old 04-30-2021, 04:46 AM   #90
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,848
Karma: 7035877
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
What would be the best way to turn my "Missing Kobo Collection" saved search into a icon for column templates?

Code:
#onkobo:true 
AND (
	#fanficcat:true 
	OR #genres:"=Fantasy" 
	OR #genres:"=Science Fiction" 
	OR #genres:"=Cozy Mystery" 
)

AND (
	#kobocoll:false 
	OR (#kobocoll:"=[Send to Device]" AND #kobocoll:#=1)
	OR (#kobocoll:"=[Kobo Store]" AND #kobocoll:#=1)
)
(btw, thanks for implementing multi-line saved searches. It's helpful )
Do you want to make the above into an if condition? If so then something like this:
Code:
program:
	if (
		$#onkobo
		&& 
		(
			$#fanficcat
			|| '^Fantasy$' inlist $#genres
			|| '^Science Fiction$' inlist $#genres
			|| '^Cozy Mystery$' inlist $#genres 
		) 
		&&
		(
			$#kobocoll == ''
			|| ( 	'^\[Send to Device\]$' inlist $#kobocoll 
					&& list_count($#kobocoll, ',') ==# 1)
			|| (	'\[Kobo Store\]$' inlist $#kobocoll 
					&& list_count($#kobocoll, ',') ==# 1)
		)
	) then
		'foo'
	fi
I made no attempt to optimize the tests. For example, the duplicated list_count can certainly be factored out.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:22 AM.


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