View Single Post
Old 04-06-2021, 05:27 AM   #27
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,495
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Could a stored template be used to share the same code between a column icon and emblem?
Yes.
Quote:
I saved some templates I have in both places (reading_status, kobo_status, and format_icons) but I am not quite sure how to get them to work. The dialog says to use the 'call' function but I think I did it wrong as I just got an error about it being unknown.
The documentation is wrong. I will fix it.

You use a stored template just as you use a template function, stored_template_name(args).

If you update source you will see some improvements in the stored template dialog. The most important is there is now a "test" button that opens a subsidiary template tester so you can try the stored template(s) without leaving the preferences dialog.

Example of definition and use of a stored template:

Definition:
Click image for larger version

Name:	Clipboard01.jpg
Views:	2111
Size:	51.9 KB
ID:	186442
The program text:
Code:
program:
	arguments(lst='No list argument given', items='');
	r = '';
	for l in items:
		if !r then
			r = str_in_list(lst, ',', l, l, '')
		fi
	rof;
	if !r then
		r = sublist(list_sort(lst, 0, ','), 0, 1, ',')
	fi;
	r;
How to call it
Code:
program: list_priority_item($tags, 'foo')
chaley is offline   Reply With Quote