I think this has been up before, but here it is again: Using %<artist>% crashes foobar. Here's the script I'm trying to use, the %<artist>% thing is almost first on line 2:
$if(%artist%,
@icon<29>%<artist>%|['['$substr(%date%,1,4)']'] $if2(@icon<11>%album%,@icon<87>-<Unknown album>-)|[$num(%tracknumber%,2) - ]%title%,
@icon<87>-<Unknown artist>-|$if(%album%,@icon<11>%album%|[$num(%tracknumber%,2) - ]%title%,@icon<87>-<Unknown album>-|%title%)
)
I'm currently using %artist% there instead; as mentioned, foobar crashes when I try to use %<artist>%.
Quoting myself here, because I have the answer. It seems all will be OK if you first make a variable with %<artist>%, like here (only the first few functions are relevant in this discussion):
$if(%artist%,$puts(ar,%<artist>%)
@icon<29>$get(ar)|['['$substr(%date%,1,4)']'] $if2(@icon<11>%album%,@icon<87>-<Unknown album>-)|[$num(%tracknumber%,2) - ]%title%,
@icon<87>-<Unknown artist>-|$if(%album%,@icon<11>%album%|[$num(%tracknumber%,2) - ]%title%,@icon<87>-<Unknown album>-|%title%)
)
Notice that I have $puts(ar,%<artist>%) on the first line, and $get(ar) on the second line instead of %<artist>% (or just %artist%).
Also, it works this way:
$if(%artist%,
@icon<29>$put(ar,%<artist>%)|['['$substr(%date%,1,4)']'] $if2(@icon<11>%album%,@icon<87>-<Unknown album>-)|[$num(%tracknumber%,2) - ]%title%,
@icon<87>-<Unknown artist>-|$if(%album%,@icon<11>%album%|[$num(%tracknumber%,2) - ]%title%,@icon<87>-<Unknown album>-|%title%)
)
Here I define the variable and use it directly ($put instead of $puts).
Now, for the big one: Why does it work these ways, and not the first one, cwbowron?