Quote:
Originally Posted by fogice
Does format_number return a text value or a numerical value? I'm kind of confused about that, because it looks like text, but then we use cmp on its outputs, which looks like it would require a number.
( edit ) Nevermind, cmp converts to integer to make the comparison.
|
All template language functions return strings.
The cmp function converts its input to float before comparing the values.
Quote:
I also don't understand how strcat doesn't always include a non-null value for final_sidx, even when sidx is null.
|
format_number returns the empty string (not the null string) if the input value is empty. finish_formatting returns the empty string if the input value is empty. Thus
Code:
sidx=field('series_index');
i=format_number(sidx, "{:02d}");
f=format_number(sidx, "{:04.1f}");
isInt=cmp(f, i, '', 'yes', '');
final_sidx=finish_formatting(
test(isInt, i, f),
'',
' ', <---- There is a space between the single quotes
' ' <---- There is a space between the single quotes
);
returns the empty string if sidx is empty. strcat is happy to concatenate the empty string, which of course does not change the result at all.