Need help on scripting

Hi, I’m fairly new to the scripting protocols and have had some success but am having problems with this one.

Unlike some other patrons :slight_smile: I do like organizing Soundtracks as a genre. It just always made it easy for me to find them.
Here’s the script I was trying

$if(releasetype,album/soundtrack),$set(genre,Soundtrack),$set(genre,%genre%))

I tried variations as well
$if(releasetype,album/soundtrack),$set(genre,Soundtrack)
$if(%releasetype%,album/soundtrack),$set(genre,Soundtrack)
$if(releasetype,“album/soundtrack”),$set(genre,Soundtrack)
$if(%releasetype%,“album/soundtrack”),$set(genre,Soundtrack)

I would love to see where I went wrong here.
Thanks

1 Like

First off: you need to have all the if clauses inside the if statement. If you do $if(foo,bar),$anything_else_here() (noticed how the parentheses are paired) the $anything_else_here() will always get evaluated. You need to do $if($eq(foo,bar),$anything_else_here()).

Anyway, on top of that, %releasetype% is a multi-value variable, so you want to use $inmulti(). Try this and see if it works for you:

$if($inmulti(%releasetype%,soundtrack),$set(genre,Soundtrack),$noop(We could set %genre% to %genre% here, but %genre% should already equal %genre%, so…))

(Note that there’s also a “hidden” variable %_secondaryreleasetype%, but I’m not sure how that works for releases with multiple secondary release types.)

1 Like

Ok thanks so much for the help
Really appreciate learning the inmulti

So I tried
$if($inmulti(%releasetype%,soundtrack),$set(genre,Soundtrack,$noop)
But I have an error that won’t let me "make it so"
It says unexpected character ‘)’ at position 69…
Basically it doesn’t like the last set and I don’t know why?

What am
I doing wrong?

If you open 3 brackets “(” then you need to close it 3 times with “)”:
$if($inmulti(%releasetype%,soundtrack),$set(genre,Soundtrack,))

As you maybe know: $noop() does nothing, just adds a remark

2 Likes

To add on to what @InvisibleMan78 said, $noop() does nothing, but it’s still a function, so if you write $noop you have to follow up with a ( and ), so

$if($inmulti(%releasetype%,soundtrack),$set(genre,Soundtrack,$noop())

should work. Or just remove the ,$noop() entirely, as @InvisibleMan78 suggested.

got it - all working well now thanks!!

One other question - if I wanted to add “Soundtrack” to the genre - in addition to the other genres, then I guess it would be a different command right? It wouldn’t be $set … but what would I use in that case?