Author Topic: replace the semicolon in a virtual tag  (Read 410 times)

monkey

  • Jr. Member
  • **
  • Posts: 92
is it possible to replace semicolon with a dot (more exactly: space dot space) " - "  in a virtual tag ?

my virtual tag is
{font: Segoe UI Symbol;Regular;10}{contrast: 100}{color: 0,118,59}<Year>{color: default} • {color: 176,0,0}<Grouping>{color: default} • {color: 0,0,220}<Genres>

tjinc

  • Sr. Member
  • ****
  • Posts: 358
You can use the $Replace function to do this - see here

So your virtual tag would be something like:
Code
$Replace(<Genres>,;," •")

monkey

  • Jr. Member
  • **
  • Posts: 92
i manage to do it using 2 virtual tags
Virt - Genres                                  :          $Replace(<Genres>,;," •")
Virt - Year/Grouping/Genres      :          {font: Segoe UI Symbol;Regular;10}{contrast: 100}{color: 0,118,59}<Year>{color: default} • {color: 176,0,0}<Grouping>{color: default} • {color: 0,0,220}<Virt - Genres>

would it be possible to write it in 1 virtual tag ?
something like (but it doesn't run...)
Virt - Year/Grouping/Genres      :          {font: Segoe UI Symbol;Regular;10}{contrast: 100}{color: 0,118,59}<Year>{color: default} • {color: 176,0,0}<Grouping>{color: default} • {color: 0,0,220}<$Replace(<Genres>,;," •")>

karbock

  • Sr. Member
  • ****
  • Posts: 358
This should do the trick:
Code
{font: Segoe UI Symbol;Regular;10}{contrast: 100}{color: 0,118,59}<Year>{color: default} • {color: 176,0,0}$Replace(<Grouping>,;," •"){color: default} • {color: 0,0,220}$Replace(<Genres>,;," •")

monkey

  • Jr. Member
  • **
  • Posts: 92
i believed having to check this solution
but i should have done an error...
virtual tag are amazing !
thanks

karbock

  • Sr. Member
  • ****
  • Posts: 358
In your attempt, you left the < > around $Replace(<Genres>,;," •"), which are normally used to enclose tag names.
Just in case: if you want to display < or >, enclose it in double quotes: "<".

hiccup

  • Sr. Member
  • ****
  • Posts: 7937
This should do the trick:
fwiw:
The replacement could also be wrapped around the whole formula, making it slightly shorter:
Code
$Replace({font: Segoe UI Symbol;Regular;10}{color: 0,118,59}<Year>{color: default}" • "{color: 176,0,0}<Grouping>{color: default}" • "{color: 0,0,220}<Genres>,;," •")
(and I removed the contrast attribute, which doesn't serve a purpose when set at 100)

@karbock, I believe (in another thread) you assumed a bug where the spaces right before {color} were removed.
I believe that is solved when putting the space-middle-dot-space between double quotes.

PS
The OP may also want to add some $IsNull to parts of the formula, so that the middle-dots do not show when tags are empty.
Last Edit: April 02, 2024, 12:27:56 PM by hiccup

karbock

  • Sr. Member
  • ****
  • Posts: 358
@hiccup
Thanks for the improvement!

I mentioned the space vanishing before a middot here,
but that middot is hardcoded in MusicBee (when displaying several tags in Album View -> Configuration -> header), thus not a part of the virtual tag formula.

hiccup

  • Sr. Member
  • ****
  • Posts: 7937
but that middot is hardcoded in MusicBee (when displaying several tags in Album View -> Configuration -> header), thus not a part of the virtual tag formula.
Ah yes, I see.
That's odd indeed.
That space seems to disappear as soon as you add any kind of formatting.
Even only having {contrast: 100} removes it.
(I am assuming that you can resolve it by adding a space at the end of an entry that contains any sort of formatting)