View Single Post
Old 06-16-2025, 07:07 PM   #843
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,033
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I have this to display icons for formats, and an unknown icon if none are present:

Code:
program: 

formats = approximate_formats();

   strcat
   (
		if "azw3" inlist formats then 'formats_azw3.png:' fi,
		if "cbz" inlist formats then 'formats_cbz.png:' fi,	
		if "epub" inlist formats then 'formats_epub.png:' fi,
		if "html" inlist formats then 'formats_html.png:' fi,
		if "mobi" inlist formats then 'formats_mobi.png:' fi,
		if "paperbook" inlist formats then 'formats_paperbook.png:' fi,
		if "pdf" inlist formats then 'formats_pdf.png:' fi,	
		if "txt" inlist formats then 'formats_txt.png:' fi,	
		if "(overdrive|paperloan)" inlist formats then 'formats_overdrive.png:' fi,	

		if list_difference(formats, 'azw3, cbz, epub, html, mobi, paperbook, pdf, txt, overdrive, paperloan', ',') then 'formats_unknown.png' fi	
   )
Very repetitive. Except for paperloan, Is there a way to regex this to a single line, and would be any faster?
ownedbycats is online now   Reply With Quote