Quote:
Originally Posted by Comfy.n
Thanks! I'm going to take a careful look at your recommendations later. Since you find that hard to read (it is, undoubtedly, but... that's how I managed to do the concatenations), I guess you'll find my "icons" column rule unimaginably chaotic:

|
No, this one is easy. Things are on separate lines and the function is clear.
For performance reasons I would suggest the following small modification. Instead of lines like this:
Code:
if 'EPUB' in $#f then icon = add_icon(icon, 'formats_epub.png') fi;
if 'AZW3' in $#f then icon = add_icon(icon, 'formats_azw3.png') fi;
Do this:
Code:
f = $#f;
if 'EPUB' in f then icon = add_icon(icon, 'formats_epub.png') fi;
if 'AZW3' in f then icon = add_icon(icon, 'formats_azw3.png') fi;
This way you evaluate the field variable only once instead of on every if line.
If you would accept alphabetic order instead of your if statement order then this would replace the long block of ifs. It isn't any faster but it is much more concise.
Code:
for f in $#f:
icon = add_icon('formats_' & lowercase(f))
rof
The same thing will work in the languages section below.