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 04-01-2025, 08:21 AM   #826
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by correoparaappzz View Post
Q:What is supposed to happen with multiple authors?
A:authors separately

Q:Is the column supposed to be hierarchical?
A:yes

Q:why are you surrounding the first letters with "[" "]"
A:i like how it looks
I think this does what you want. To make a valid hierarchical item, in authors it replaces periods and commas, and in series it replaces periods. If you have commas in series names then you must replace those as well.
Code:
program:
	def first_letter(x):
		return strcat('[', substr(x, 0, 1), ']')
	fed;

# Replace periods with unicode "One Dot Leader" (․)
	period = '․';
# Replace commas with unicode "Small Comma" (﹐)
	comma = '﹐';

	if $series then
		series = strcat('.', first_letter($series), '.', re($series, '\.', period))
	else
		series = '.Standalone'
	fi;

	sep = '';
	result = '';
	for aut in 'authors':
		result = strcat(result, sep, first_letter(aut), '.', re(re(aut, '\.', period), ',', comma), series);
		sep = ','
	rof;
	result
chaley is offline   Reply With Quote
Old 04-01-2025, 01:07 PM   #827
correoparaappzz
Connoisseur
correoparaappzz began at the beginning.
 
Posts: 63
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
Quote:
Originally Posted by chaley View Post
I think this does what you want. To make a valid hierarchical item, in authors it replaces periods and commas, and in series it replaces periods. If you have commas in series names then you must replace those as well.
Code:
program:
	def first_letter(x):
		return strcat('[', substr(x, 0, 1), ']')
	fed;

# Replace periods with unicode "One Dot Leader" (․)
	period = '․';
# Replace commas with unicode "Small Comma" (﹐)
	comma = '﹐';

	if $series then
		series = strcat('.', first_letter($series), '.', re($series, '\.', period))
	else
		series = '.Standalone'
	fi;

	sep = '';
	result = '';
	for aut in 'authors':
		result = strcat(result, sep, first_letter(aut), '.', re(re(aut, '\.', period), ',', comma), series);
		sep = ','
	rof;
	result
correoparaappzz is offline   Reply With Quote
Old 04-09-2025, 09:20 PM   #828
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: 10,647
Karma: 74166147
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:
cost = $$#purchasecost;

	switch_if(
		cost == 'none', '',
		'[Bundle]' inlist $#admintags, '[Bundle]',
		'kobopoints:' inlist $#admintags, '[Kobo VIP]',
		cost ==# '00.00', '$0.00',
		cost <=# '00.99', '$0.01 - $0.99',
		cost <=# '04.99', '$1.00 - $4.99',
		cost <=# '10.00', '$5.00 - $9.99',
		cost <=# '15.00', '$10.00 - $14.99',
		cost <=# '15.00', '$10.00 - $14.99',
		cost <=# '20.00', '$15.00 - $19.99',
		cost <=# '30.00', '$20.00 - $29.99',
		'$30.00 and up' 
	)

This returns [Bundle] for nearly everything, even when the entry doesn't exist in admintags. It doesn't happen when I remove square brackets in the test. What happened?
ownedbycats is online now   Reply With Quote
Old 04-10-2025, 05:56 AM   #829
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
cost = $$#purchasecost;

	switch_if(
		cost == 'none', '',
		'[Bundle]' inlist $#admintags, '[Bundle]',
		'kobopoints:' inlist $#admintags, '[Kobo VIP]',
		cost ==# '00.00', '$0.00',
		cost <=# '00.99', '$0.01 - $0.99',
		cost <=# '04.99', '$1.00 - $4.99',
		cost <=# '10.00', '$5.00 - $9.99',
		cost <=# '15.00', '$10.00 - $14.99',
		cost <=# '15.00', '$10.00 - $14.99',
		cost <=# '20.00', '$15.00 - $19.99',
		cost <=# '30.00', '$20.00 - $29.99',
		'$30.00 and up' 
	)

This returns [Bundle] for nearly everything, even when the entry doesn't exist in admintags. It doesn't happen when I remove square brackets in the test. What happened?
The left-hand side of inlist (the search string) is a regular expression. Square brackets are regexp character classes. You need to escape them if you want them to be normal characters. Use
Code:
		'^\[Bundle\]$' inlist_field '#admintags', '[Bundle]',
The anchors ensure that the value matches the entire list item, not a substring.

Note that you can also use the str_in_list() function that doesn't use regular expressions and returns 'found_val' only if the value matches an entire list item.
chaley is offline   Reply With Quote
Old 04-10-2025, 03:37 PM   #830
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: 10,647
Karma: 74166147
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks. I think I ran into something similar once before
ownedbycats is online now   Reply With Quote
Old 04-16-2025, 10:24 AM   #831
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: 10,647
Karma: 74166147
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Can this be used in a plugboard? I would like to remove the series name on device if I have only 1 book.

Code:
program:

switch_if(
	series_multibook(), $series,
	''
	)
ownedbycats is online now   Reply With Quote
Old 04-16-2025, 11:16 AM   #832
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Can this be used in a plugboard? I would like to remove the series name on device if I have only 1 book.

Code:
program:

switch_if(
	series_multibook(), $series,
	''
	)
It should work.
chaley is offline   Reply With Quote
Old 04-22-2025, 11:11 PM   #833
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: 10,647
Karma: 74166147
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
In another post, I asked about setting specific time. Now I'd like to know if possble to:

1. Take current date.
2. Subtract one day (April 23 -> April 22).
3. Set the time to 23:59 of that date.

This would be for Reading Goal setting the #lastread - I update my daily page at end of day, but sometimes forget till next morning which messes up the page-per-day count.
ownedbycats is online now   Reply With Quote
Old 04-23-2025, 07:56 AM   #834
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
In another post, I asked about setting specific time. Now I'd like to know if possble to:

1. Take current date.
2. Subtract one day (April 23 -> April 22).
3. Set the time to 23:59 of that date.

This would be for Reading Goal setting the #lastread - I update my daily page at end of day, but sometimes forget till next morning which messes up the page-per-day count.
Code:
program:
	date_arithmetic(re(today(), 'T.*\+', 'T00:00:00+'), '-1m')
This gets the current date and time, sets the time to midnight, then subtracts one minute from that to get 23:59 on the previous day.
chaley is offline   Reply With Quote
Old 04-23-2025, 05:37 PM   #835
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: 10,647
Karma: 74166147
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I'm not sure why, but can't get it working. Returns current datetime minus 1 minute.
ownedbycats is online now   Reply With Quote
Old 04-23-2025, 05:44 PM   #836
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I'm not sure why, but can't get it working. Returns current datetime minus 1 minute.
Works fine for me. The time is set to 23:59. The date might not be yesterday because of timezones.

Please attach both what today() and the re() return so I can check the regular expression. Both must be in ISO format.
chaley is offline   Reply With Quote
Old 04-23-2025, 05:49 PM   #837
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,327
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Try this:
Code:
program:
	date_arithmetic(re(today(), 'T.*([+-])', 'T00:00:00\1'), '-1m')
chaley is offline   Reply With Quote
Old 04-23-2025, 06:52 PM   #838
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: 10,647
Karma: 74166147
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
re(): 2025-04-23T19:51:10.719873-03:00
today(): 2025-04-23T19:50:10.719873-03:00

The new code works.
ownedbycats is online now   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 198 04-26-2025 07:02 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 09:55 AM.


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