View Single Post
Old 01-17-2021, 06:51 AM   #7
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,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
	if field('#readorder') then
		 template('Reading List: {#readorder} #{#readorder_index:0>2s}')
	else
		if field('#fanficcat') then
			template('{#fanficcat:'sublist(list_sort($, 0, ','), 0,1,',')'} | {#fanficstatus}')
		fi
	fi
Gives me a "Missing closing parenthesis near 'sublist'" error. I tried adding one in a few places where I thought they might belong but it didn't go away. did I make a mistake of placing it?
Mixing TPM and GPM can lead to very strange errors because of quote matching. In your case the single quote after template( matches the quote after the colon, messing up the expression. To fix it you must use a combination of single and double quotes and ensure that the quotes balance correctly. In your case change the first and the last single quote to double quotes, giving you
Code:
template("{#fanficcat:'sublist(list_sort($, 0, ','), 0,1,',')'} | {#fanficstatus}")
I recommend that you don't intermix the two language forms. Instead of using "template" with TPM, construct the result yourself. For example (and using columns I have),
Code:
strcat(sublist(list_sort(field('#genre'), 0, ','), 0,1,','), ' | ', field('author'))
Not only is this safer, it is significantly faster. If your template uses prefixes and suffixes then use the finish_formatting() function.
chaley is offline   Reply With Quote