View Single Post
Old 07-16-2022, 04:31 PM   #9
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,458
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ackomb View Post
I'm wondering though if there is a way to make it more like this:

Code:
program:
	list = 'bus, car, ferry, red'
	output = '';
	for item in $#cumstom_column:
		if  	  item == in list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Yes, but the syntax is different from what you wrote. Here is your template, corrected.
Code:
program:
	sample_input = 'bus, carpool, ferry, redbus';
	list = 'bus, car, ferry, red';
	output = '';

# Change $#custom_column to sample_input so the value exists, avoiding an error.
	for item in sample_input:
		if ('^' & item & '$') inlist list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Quote:
Also, are there limitations to the elif statements within one template? I've had Calibre crash sometimes running an action chain, so I'm chopping them up in bits and pieces anyway, just want to know the limitations.
There is recursion in parsing so the default limit to elifs is 1000. Do you think you might go over that?
chaley is offline   Reply With Quote