SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

Ifnotempty Function Improvment

hello,

I was wondering if you can help me to write a better ‘ifnotempty’ function…

Currently ifnotempty outputs the specified mask and then a separator. I’d like help in writing it so it instead of a separator it outputs a string including the mask and also an else.

For example I would write something like, ifnotempty(year, ’ [’ + year + ‘]’, ‘’)

So it works kind of like an if, then, else. If NotEmpty year, then do this, else do this.

Can you help me create a ifnotempty2 that would help me to accomplish this? Thank you!!

What about this

 function ifnotemptyelse(value1,value2,sep){
     return value1.length > 0 ? value2 :value2.length > 0 ? sep:'' ;
 }

use like this

ifnotemptyelse(album,'['+album+']','')

Excellent, thank you!!