# How to use conditional statements alongside variables?

**URL:** https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987
**Category:** Web Sources Discussion
**Created:** [April 3, 2026, 7:35am UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987 "2026-04-03T07:35:55Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![anton](https://community.mp3tag.de/user_avatar/community.mp3tag.de/anton/32/16235_2.png) [@anton](https://community.mp3tag.de/u/anton)
#### Post date: [April 3, 2026, 7:35am UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/1 "2026-04-03T07:35:55Z")

</div>

Hi all,

(Edit at 2026-04-03 22:00 CST - Whole post was reworded because, as pointed out, it didn’t much sense what I was trying to ask. Being sleep deprived and taking flu meds didn’t helped at all - lesson learned)

Well, as title says, is it possible to validate the current value of a variable to determine what the script will do next?

Long story short: Using HTML scrapping (as no API, nor JSON are available) current version of script can get Artist name, and Release Type (e.g., Split, Full-Length, Single, etc).

However, due to how albums with multiple artist are displayed, to get the proper artist for each track Artist’s value needs to be changed depending if current album has an specific Release Type (Split) and leave it alone if it is not. Basically something like this:

> IF RELEASE\_TYPE is “Split” THEN  
> ARTIST = “New Value”  
> END IF

As per current HTML design, Artist value will always be found before the Release Type.

So, part of my initial idea was to validate RELEASE\_TYPE’s value to determine if Artist’s value needs to be updated or not - but it so far it hasn’t been possible for me to achieve that.

Worth to mention that most of my attempts have gravitated around [this potential solution](https://community.mp3tag.de/t/variables-in-source-scripts/51644/4) but either there’s something that I am missing/doing wrong, or something else is going on, because I am not able to make it work as expected.

Any ideas how to validate a variable’s value? Or is something that is not possible?

Nonetheless, thanks in advance.

Regards.

---

<div class="post-metadata">

### Author: ![AreDigg](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/bbe5ce/32.png) [@AreDigg](https://community.mp3tag.de/u/AreDigg)
#### Post date: [April 3, 2026, 9:16am UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/2 "2026-04-03T09:16:18Z")

</div>

It is not clear what you are attempting to do. There should not be percents in the release\_type. It is better to use conditional when the value is occurring in the html, then store something temporary depending on the condition if you need to use it later. I would recommend using the debug output to see how MP3tag is building the buffers.

---

<div class="post-metadata">

### Author: ![arb](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@arb](https://community.mp3tag.de/u/arb)
#### Post date: [April 3, 2026, 3:09pm UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/3 "2026-04-03T15:09:29Z")

</div>

You might need to re-word or point out the exact problem you’re having, sorry. 😟 What site are you trying to scrape from and are there any test albums/artist we can use to replicate what you’re doing?

```auto
SayOutput "%RELEASE_TYPE%"

```

That should be okay as using a `%placeholder%` in this example means you can swap around the name of the output buffer to look for, which could be “Split” or “Not-split” etc.

> [@AreDigg](#):
>
> I would recommend using the debug output to see how MP3tag is building the buffers.

This, even better show us what part of the debug process where you’re not getting something processed right and what result you’re expecting instead.

* * *

If I'm reading this right though, maybe your code's looking for a value in the wrong place? The way `If` conditional commands work is by comparing what’s currently in the current selection/pointer/whatever you want to call it; in a debug file, it's whatever value is in **Line and Position** , where other commands like `FindLine` and `MoveLine` will temporarily store their data. Commands like `SayRest` then move that data into an **Output** buffer. For example, here's a bit from a debug file from a source looking for an output buffer called "TV":

```auto
Script-Line : 38
Command : if
Parameter 1 : >TV<

JSON objects : ><
JSON loops : ><

Output : >Movie<

Line and position:
TV

```

This would match, as it finds TV where it wants it, not Movie which is the actual contents of the currently loaded output buffer as shown in **Output**. So to get that `splitConstant` value read by an `If`, you can use the `Use` command to load whatever data you want into that section:

> **Edit: Don't use this, this is stupid. My fault. Read further down.**
>
> ```auto
> Use "splitConstant"
> IfOutput "splitConstant"
> set "Artist" ""
> endif
> 
> ```

---

<div class="post-metadata">

### Author: ![anton](https://community.mp3tag.de/user_avatar/community.mp3tag.de/anton/32/16235_2.png) [@anton](https://community.mp3tag.de/u/anton)
#### Post date: [April 4, 2026, 4:31am UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/4 "2026-04-04T04:31:26Z")

</div>

Hi @AreDigg and @arb, thanks for the reply - and thank you for pointing out that my initial post was a mess… I think that I’ve fixed it, or at least is now a little bit more simpler.

As for your questions:

> [@arb](#):
>
> What site are you trying to scrape from and are there any test albums/artist we can use to replicate what you’re doing?

I’m trying to do this for [Metal Archives](https://www.metal-archives.com/) and these are the examples for a "[Full-Length Album](https://www.metal-archives.com/albums/After_Forever/Prison_of_Desire/5869)” and a “[Split Album](https://www.metal-archives.com/albums/After_Forever/Metal-Sampler%2C_H%C3%B8st_2001/1094453)“. In both cases the Release Type field can be found with the proper value.

> [@arb](#):
>
> show us what part of the debug process where you’re not getting something processed right and what result you’re expecting instead.

Sure thing.

Although I’ll attach the script on this reply (just with the current conflicting logic), this is how currently script attempts to validate the value

```auto
set "splitConstant" "Split"
set "temp_Type" ""
outputto "temp_Type"
SayOutput "RELEASE_TYPE"

IfOutput "splitConstant"
    set "Artist" "Output was Split"
else
    set "Artist" "Output wasn't Split"
endif

```

Using either link that I provided above, result is the same: `Output was Split`

Debug for Full-Length is:

```auto
------------------------------------------------------------

Script-Line : 43
Command : ifoutput
Parameter 1 : >splitConstant<

Output : >Full-length<

Line and position:
              Full-length
                      ^

------------------------------------------------------------

Script-Line : 44
Command : set
Parameter 1 : >Artist<
Parameter 2 : >Output was Split<

Output : >Full-length<

Line and position:
              Full-length
                      ^

------------------------------------------------------------

```

And for Split is:

```auto
------------------------------------------------------------

Script-Line : 43
Command : ifoutput
Parameter 1 : >splitConstant<

Output : >Split<

Line and position:
            Split
                ^

------------------------------------------------------------

Script-Line : 44
Command : set
Parameter 1 : >Artist<
Parameter 2 : >Output was Split<

Output : >Split<

Line and position:
            Split
                ^

------------------------------------------------------------

```

And basically this is why I think that I am missing something important/critical here - asides how “regular” If works (based on current line/position on HTML - that part I kinda get it right).

> [@AreDigg](#):
>
> It is better to use conditional when the value is occurring in the html

Unfortunately, in this case the order of the values are set in a way that I can’t see a feasible way to do it, as Artist is acquired first, then the Release Type, and if needed, Artist replacement is way down the HTML document.

Of course, I’ll be more than happy if I am proved wrong, because at this point I have zero ideas left 😅.

In any case, I really appreciate the comments and suggestions.

Thanks in advance.

[RELEASE\_TYPE\_WITH\_IF\_TEST.src](https://community.mp3tag.de/uploads/short-url/sJJGfXD5q0Ktd7YLvGvLdZyPrXP.src) (1.3 KB)

---

<div class="post-metadata">

### Author: ![arb](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@arb](https://community.mp3tag.de/u/arb)
#### Post date: [April 4, 2026, 3:23pm UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/5 "2026-04-04T15:23:00Z")

</div>

Cool, try this:

[RELEASE\_TYPE\_WITH\_IF\_TEST\_BACK\_AT\_YOU.src](https://community.mp3tag.de/uploads/short-url/xg0ssiY9kWyKQFOKtwE55VnzbW5.src) (1.5 KB)

I disregarded `splitConstant` and aimed for the value of `RELEASE_TYPE` which is what you’d ideally want to use. I’m also ultimately amending my previous suggestion. 😅

Your biggest problem was using `IfOutput`, which only [checks if there’s actually an output buffer](https://docs.mp3tag.de/tag-sources/development/#:~:text=IfOutput,buffer%20named%20S.) called what you want, not the actual value of that buffer (I can’t recall if it actually requires content in the buffer to be recognised or just goes by its existence). `If` will check whatever’s in **Line and Position** , which is what you want.

Next, your code actually keeps the previous value from your `# Type` section loaded in **Line and Position** up to the `IfOutput` command so it’s still usable... almost.

```auto
Script-Line : 44
Command : if
Parameter 1 : >Split<

Output : >Split<

Line and position:
	          Split
                ^

```

The pointer in **Line and Position** , i.e. the `^`, isn’t at the start of “ Split” string so the match will fail.

I replaced your `RegexpReplace` with the regex `<[^>]+>` with `(\s+)?<[^>]+>` to remove the leading spaces from your values below `band_name` and `Type:` so it then becomes:

```auto
Script-Line : 44
Command : if
Parameter 1 : >Split<

Output : >Split<

Line and position:
Split
     ^

```

🫩

The `^` still isn’t where we want it because the previous `SayRest` moves the pointer along the line. If we use `MoveChar` to set it back, it’ll throw an error if it’s too far along and “Full-length” and “Split” are different lengths so that’s a hassle.

So the solution is `Use “%RELEASE_TYPE%”`: the percents turn the `RELEASE_TYPE` output into its actual value, the `Use` command loads it into **Line and Position**. This actually also removes the leading spaces so that updated regex becomes … more of a cosmetic nicety but it does guarantee your values won’t have that spacing. 🤓

So by ultimately using:

```auto

Use "%RELEASE_TYPE%"
If "Split"

```

you get:

```auto
Script-Line : 43
Command : use
Parameter 1 : >Full-length<

Output : >Full-length<

Line and position:
Full-length
^

------------------------------------------------------------

Script-Line : 44
Command : if
Parameter 1 : >Split<

Output : >Full-length<

Line and position:
Full-length
^

------------------------------------------------------------

Script-Line : 47
Command : set
Parameter 1 : >Artist<
Parameter 2 : >Output wasn't Split<

Output : >Full-length<

Line and position:
Full-length
^

```

and:

```auto
Script-Line : 43
Command : use
Parameter 1 : >Split<

Output : >Split<

Line and position:
Split
^

------------------------------------------------------------

Script-Line : 44
Command : if
Parameter 1 : >Split<

Output : >Split<

Line and position:
Split
^

------------------------------------------------------------

Script-Line : 45
Command : set
Parameter 1 : >Artist<
Parameter 2 : >Output was Split<

Output : >Split<

Line and position:
Split
^

```

😬

(oh, I also changed the debug files to save in the **sources** folder. Might be more convenient debugging and editing from where your source works from but save it where you want 😉 )

---

<div class="post-metadata">

### Author: ![anton](https://community.mp3tag.de/user_avatar/community.mp3tag.de/anton/32/16235_2.png) [@anton](https://community.mp3tag.de/u/anton)
#### Post date: [April 6, 2026, 5:55am UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/6 "2026-04-06T05:55:31Z")

</div>

Hi!

First and foremost: Whoa, that was amazing! It worked like a charm.

I am very thankful for your help, as well for the patience. I learned quite a few new things, as well to better understand how the Web Scripts Framework works in these cases.

Also, due to have a kinda outdated version of the application, and I wasn’t aware of `Use` command (the version of MP3Tag that I had simply threw an error when attempting to use it).

In any case your solution, as well explanations, have helped me not only with my original issue, but also to do some additional things that were giving me some issues.

Once again, thank you so much!

Hope you’re having a great day.

Regards.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [April 13, 2026, 5:56am UTC](https://community.mp3tag.de/t/how-to-use-conditional-statements-alongside-variables/70987/7 "2026-04-13T05:56:21Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
