Author Topic: Need help with Functions  (Read 187 times)

cereal_eater

  • Jr. Member
  • **
  • Posts: 24
Hello musicbee community,

using a virtual tag, I'd like to display Album [Mediatype Albumtype Releasetype], but not all tag fields have a value.

With this code

Code
<Album> [$Trim($IsNull(<Mediatype>,,<Mediatype>" ")$IsNull(<Albumtype>,,<Albumtype>" ")$IsNull(<Releasetype>,,<Releasetype>" "))]
a space and the square brackets are still visible, when Mediatype, Albumtype and Releasetype are empty. I couldn't find a way to hide them in that case.

Has anyone an idea how to only display only Album, when the three tag fields are empty?

Pickles7853

  • Full Member
  • ***
  • Posts: 151
I haven't tested it, but from just looking at it this might work...

Code
<Album> $IsNull(<Mediatype><Albumtype><Releasetype>,,[$Trim($IsNull(<Mediatype>,,<Mediatype>" ")$IsNull(<Albumtype>,,<Albumtype>" ")$IsNull(<Releasetype>,,<Releasetype>" "))])

If not you could use $And's

cereal_eater

  • Jr. Member
  • **
  • Posts: 24
Thanks a lot Pickles7853,

that worked, but left a space after Album if the three tag fields had no value. I tweaked your code to
Code
<Album>$IsNull(<Mediatype><Albumtype><Releasetype>,," ["$Trim($IsNull(<Mediatype>,,<Mediatype>" ")$IsNull(<Albumtype>,,<Albumtype>" ")$IsNull(<Releasetype>,,<Releasetype>" "))])
and now everything is great.  :)

P.S.: I think, that group intelligence is superior to AI, which failed to provide a solution here.