View Single Post
Old 03-26-2013, 08:03 AM   #5
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,529
Karma: 8075938
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Use a general program mode template.

The following template shows one way to do variable formatting.
Code:
program:
	si = field('series_index');
	index_val = test(
			field('series'),
			contains(si, '\.', 
				format_number(si, '{0:04.1f}'), 
				format_number(si, '{0:02d}')), 
			'');
	finish_formatting(index_val, '', '', '.')
You will of course need to add the rest of the template to the result value, probably using the template function.

An alternate way to do it would be to generate the template string you want depending on the value of series and series_index, then return the result of evaluating that template. Which is easier for you depends on how you think.
chaley is offline   Reply With Quote