If-Then-Else for Variables

Main discussion forum
Post Reply
Arthur Dent
Newbie
Newbie
Posts: 1
Joined: Sun Jul 30, 2017 1:54 pm

If-Then-Else for Variables

Post by Arthur Dent »

Hi,

I'd like to have an "If-Then-Else" structure for variables. I have two types of filenames:
"Dance - Titel - Artist" and "Titel - Artist".

If I want to get the artist out of the filename it's easy:
%?F3;F2%
This is like "If F3 exists, use F3, else use F2"

But for the title I would need something like "If F3 exists, use F2, else use F1".

Alternatively a F1/F2/F3 variable which does not count from the beginning, but from the end, would also solve the task.

CU,
Arthur Dent

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: If-Then-Else for Variables

Post by jtclipper »

You can enforce complex logic using variable scripts in File/Options/Variables %..% (user page)

This one should work ok for you

Code: Select all

begin
  if gTag.ParseValue( '%F3%', false, false ) = '' then begin
     var_result( gTag.ParseValue( '%F1%', false, false ) );
  end else begin
     var_result( gTag.ParseValue( '%F2%', false, false ) );
  end;
end.
Click manage create a new one and save it as a file, then it will be available at the user submenu

Post Reply