View Single Post
Old 06-30-2023, 10:01 AM   #953
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,354
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by zardoxnet View Post
I am working on a metadata plugboard to be used when exporting a book and including all relevant details in the new comment field of the created book. So I have a template program and concatenate all values. The part I am looking for help with is in taking 3 values and printing them out with commas between them. Any of the 3 values might be blank, so I don't want to print a comma for those and don't want a hanging comma.
[snip]
Try this:
Code:
program:
	ids = list_remove_duplicates($#isbn_enter & ',' & $#isbn_p_enter & ',' 
		& $#isbn_asin, ',');
	if ids then
		OUTPUT6 = strcat('<tr><td>Identifier:</td><td>', ids, '</td></tr>')
	else
		OUTPUT6 = ''
	fi
This works because list_remove_duplicates():
  • removes empty items as well as duplicates.
  • removes leading and trailing spaces.
  • if the separator is ',' then it (like most of the list functions) rebuilds the list using ', ' (comma space).
  • returns the empty string if the list is empty.
chaley is offline   Reply With Quote