View Single Post
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: 11,044
Karma: 75555555
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:	426
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