![]() |
#1 |
Junior Member
![]() 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 goal would be: universe.char1, universe.char2, etc What am I missing? Or is it not possible? Any help would be appreciated |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() 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
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
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 |