Cascading if statement


#1

Hi,

I am trying to use the following if statements to format the Album tag based on if either the temporary ReleaseEdition and ReleaseType tags or both are filled. However I can not get the statement covering both tags to process.

[#0]
T=5
F=ALBUM
1=$if(%releaseedition%,%album% '{'%releaseedition%'}',if(%releasetype%,%album% '{'%releasetype'}',if(%releaseedition% %releasetype%,%album% '{'%releaseedition% %releasetype%'}',%album%)))

#2

If you don't want to find all your syntax errors for the formula
$if(x,y,z) = if x is true, y is returned, otherwise z.
you can try to make 3 much easier, single actions.

But first you have to explain what do you want to do exactly?
If your temporary tag %releaseedition% is filled, then you want to fill the official tag %album% with the content of {%releaseedition%} (inlcuding curly brackets)?


#3

The first two if statements work correctly, it's the third that is this issue.
if(%releaseedition% %releasetype%,%album% '{'%releaseedition% %releasetype%'}',%album%)

I am trying to test if both %releaseedition% and %releasetype% tags exist then append them to the Album tag in curly braces.

Desired outcomes:

AlbumTitle {Deluxe}, AlbumTitle {Single} or AlbumTitle {Deluxe Single}.


#4

Something like
if($and(%releaseedition%, %releasetype%),%album% '{'%releaseedition% %releasetype%'}',%album%)

Boolean functions:
$and(x,y) -> returns true if x and y are true


#5

if(,Heroes (We Could Be) {Deluxe Single},Heroes (We Could Be))


#6

Copy & paste your line 1= into an editor like notepad++ and break the lines like

$if(%releaseedition%,%album% '{'%releaseedition%'}',
 if(%releasetype%,   %album% '{'%releasetype'}',
 if($and(%releaseedition% , %releasetype%) ,%album% '{'%releaseedition% %releasetype%'}',%album%)))

Then re-read my first answer with the $if(x,y,z)-command

You can read your 3 lines above like:
IF %releaseedition% is true (= in this case not empty), then fill %album% with the content of {%releaseedition%}
IF %releaseedition% is false (= in this case empty), then check this:
IF %releasetype% is true (= in this case not empty), then fill %album% with the content of {%releasetype%}

if you complete the $if(x,y,z) logic for OTHERWISE Z
In which case will your 3rd IF-condition ever be reached and executed?


#7

I've decided to separate each statement into individual actions. The previous reply is the result of the if $and statement only.


#8

Did you forget the leading dollar sign $ in front of the IF-condition if you use it as individual action?

$if($and(%releaseedition% , %releasetype%) ,%album% '{'%releaseedition% %releasetype%'}',%album%)
which reads:
IF both %releaseedition% AND %releasetype% are true (= in this case not empty), then fill %album% with the content of {%releaseedition% SPACE %releasetype%}
IF one of %releaseedition% OR %releasetype% are false (= in this case empty), then let %album% remain unchanged


#9

Oops, my bad. Thanks :slight_smile:


#10

Another way is to use the power of square brackets in the format string, like this:
$Replace(%album% [ {%releaseedition% %releasetype%}],{ ,{, },})

See here: Characters with special functionality