Latest WACUP public preview for x86 & x64 is build #23960 (March 1st 2026) (x86 & x64 changelogs)
Latest restricted WACUP beta release is build #23960 (March 1st 2026) (x86 & x64 changelogs)

Author Topic: ATF for conditional delimeter between two optional variables  (Read 13421 times)

qwerty

  • Full Member
  • ***
  • Posts: 10
    • View Profile
    • qwerty.xyz
ATF for conditional delimeter between two optional variables
« on: August 08, 2025, 12:43:59 PM »
I have an optional title section [ '('%album%[ #%tracknumber%][, %year%]')']  e.g. " (Album #1, 2020)", however, this also produces " (, 2020)" or " ( #2)", which is undesirable.

I am trying to work around it with nested ifs, but I was wondering if there is or could be some chaining function that would achieve this for us.
This is my workaround using ifs:
Code: [Select]
[ '('
%album%
$IfStrEqual('yy',$if(%album%,'y',)$if(%tracknumber%,'y',),' ')
[#%tracknumber%]
$IfStrEqual('yy',$if($if3(%album%,%tracknumber%),'y',)$if(%year%,'y',),', ')
[%year%]
')']


If it is possible to have a new function, I would be happy to come up with a specification and test cases, albeit it might take weeks before finishing, to make such function really robust and not just fit my usecase.

---

Another (possibly simpler) solution could be a trimming function which would cut off any specified leading and trailing characters, e.g.

$trim2(a1, characterSet) using characters in characterSet as trimming candidates for a.
$trim2(%album%[ #%tracknumber%][, %year%],' ,')
result:
"Album #2, 2020" -> "Album #2, 2020"
" #2, 2020" -> "#2, 2020"
", 2020" -> "2020"
« Last Edit: August 08, 2025, 12:57:06 PM by qwerty »