Quote:
Originally Posted by Comfy.n
Hi,
I'm using the above composite to display human readable format sizes and this looks fine on Book Details but I wanted to prevent the trailing pipe showing when there's only one format available, so instead of...
💾 EPUB: 1.2 MB |
the ideal output would be:
💾 EPUB: 1.2 MB
Ideas?
|
Put this just before the last line:
Code:
if substr(out, -2, 0) == '| ' then
out = substr(out, 0, -3)
fi;
For fun, here is a template that does almost the same thing but
hundreds of around fifty times faster. A difference is that the formats are output in alphabetic order, not the order you specified.
Code:
program:
out = ' 💾 ';
fmts = list_sort(formats_sizes(), 0, ',') ;
for fmt_data in fmts:
fmt = sublist(fmt_data, 0, 1, ':');
size = sublist(fmt_data, 1, 2, ':');
str = if size ># 0 then strcat(fmt, ': ', human_readable(size), ' | ') else '' fi;
out=strcat(out, str)
rof;
if substr(out, -2, 0) == '| ' then
out = substr(out, 0, -3)
fi;
out