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 07-07-2025, 09:47 PM   #1
CAIArchive
Junior Member
CAIArchive began at the beginning.
 
CAIArchive's Avatar
 
Posts: 2
Karma: 10
Join Date: May 2025
Device: Android Tablet
Column for characters in universe

created a column built from other columns, behaves like tags. I'm not great at code, but so far I have:

Code:
program:
		if (ifempty(field('#chars'), ''))
		then list_union(field('#chars'),(first_non_empty(field('#universe'), field('series'), field('title'))), '.') fi
Its almost correct except I cant figure out how to make it apply the part starting with (first_non_empty) to item with the possible list that is (chars). The end goal is, I can type main characters names into (chars) and calibre will automagically put the highest level category followed by a '.' followed by each char name into the charsort column. The above catches the first category and populates correctly, all the rest of the chars are just the name itself.

goal would be: universe.char1, universe.char2, etc

What am I missing? Or is it not possible?

Any help would be appreciated
CAIArchive is offline   Reply With Quote
Old 07-08-2025, 06:16 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,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Moderator Notice
Moved to its own thread for better visibility
chaley is offline   Reply With Quote
Advert
Old 07-08-2025, 06:37 AM   #3
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,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I think this does what you want. The trick is to loop through the characters. Your template operated on only the first character in the list.
Code:
program:
	result = '';
	if $#chars then
# Loop through the characters adding the universe prefix
		for char in '#chars':
			result = strcat(result, first_non_empty($#universe, $series, $title), '.', char, ',')
		rof;
# Clean up the list, adding spaces and removing the trailing comma
		result = list_union(result, '', ',')
	fi;
	result
chaley is offline   Reply With Quote
Old 07-08-2025, 06:59 AM   #4
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,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
This is a more efficient version of the template, making use of the fact that the universe prefix doesn't change for a given book.
Code:
program:
	result = '';
	if $#chars then
# The universe name is a constant for each book. Compute it once for efficiency
		prefix = strcat(result, first_non_empty($#universe, $series, $title), '.');

# Loop through the characters adding the universe prefix to the character
# and adding a trailing comma
		for char in '#chars':
			result = strcat(result, prefix, char, ',')
		rof;

# Clean up the list, adding spaces and removing the trailing comma
		result = list_union(result, '', ',')
	fi;
	result

Last edited by chaley; 07-08-2025 at 07:39 AM. Reason: Fix mistake in template
chaley is offline   Reply With Quote
Old 07-08-2025, 05:35 PM   #5
CAIArchive
Junior Member
CAIArchive began at the beginning.
 
CAIArchive's Avatar
 
Posts: 2
Karma: 10
Join Date: May 2025
Device: Android Tablet
Thank you so much. That is absolutely what I was trying to do. The explanations helped also. Thank you again
CAIArchive is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
replace the encoded characters "&#…;" with accented characters JeanM Editor 2 12-15-2024 02:43 AM
Help with "Shared Universe" custom column zaroz Library Management 3 11-24-2021 11:30 AM
Enhancement request: special characters, invisible characters and html entities. PenguinCEO Editor 15 04-08-2020 05:26 PM
custom column: count number of characters (in book path) miquele Library Management 25 09-21-2012 01:54 PM
¿Convert unicode decomposed characters to unique/normal characters? JohnQwerty Calibre 3 04-05-2012 12:08 PM


All times are GMT -4. The time now is 11:55 PM.


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