# Comments on "Endif" disable the command

**URL:** https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645
**Category:** Fixed Bugs
**Tags:** bug-fixed
**Created:** [August 17, 2024, 8:31pm UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645 "2024-08-17T20:31:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![rboss](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rboss](https://community.mp3tag.de/u/rboss)
#### Post date: [August 17, 2024, 8:31pm UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645/1 "2024-08-17T20:31:30Z")

</div>

This has left me baffled for the last 3 hours.

When working on a script, usually I write comments after a certain command to remind me of why said command is/is not needed, like

```auto
If "string" ##_ some comment
	(...)

Endif ##_ (If "string")

```

and have done so for several years.

Today I came across this error  
 ![imagem](https://community.mp3tag.de/uploads/default/original/3X/2/5/25e8420268985cc91ad48b5379fc7b6d1342a4ee.png)

on a script where I have verified, checked and double-checked that the syntax is correct.  
After 2 hours of troubleshooting, I boiled down a test script to these lines:

```auto
# Test script

[Name]=
[BasedOn]=www.google.com
[IndexUrl]=http://www.google.com
[AlbumUrl]=
[SearchBy]=Query:||string||%s
[WordSeparator]=
[IndexFormat]=
[Encoding]=

[ParserScriptIndex]=...

If ""
Endif ##_ some comment ##

[ParserScriptAlbum]=...

```

This returns the same error.  
By removing the comment in the `EndIf` command, the script now runs (it won't do much, but it won't return a error).

But since I have been adding comments in my coding for years, this didn't made sense.

What I learned after (more) testing out was that _this_ script

```auto
# Test script

[Name]=
[BasedOn]=www.google.com
[IndexUrl]=http://www.google.com
[AlbumUrl]=
[SearchBy]=Query:||string||%s
[WordSeparator]=
[IndexFormat]=
[Encoding]=

[ParserScriptIndex]=...

If ""
Endif ##_ some comment ##
# <-- just add this comment mark

[ParserScriptAlbum]=...

```

will run. And the only difference is the presence of a comment mark `#` after `Endif`.

After some more tests I came up with the hypothesis that the last line in a `[Parser...]` block must not be a command with a comment, or that command will not run. Having a command without comments or a comment after the last commented command will escape this behavior.

Can someone reproduce this and validate my theory?  
Is this a bug?

---

<div class="post-metadata">

### Author: ![rboss](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rboss](https://community.mp3tag.de/u/rboss)
#### Post date: [August 18, 2024, 12:41am UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645/2 "2024-08-18T00:41:20Z")

</div>

4h later........

Update: There is something wrong with my installation, although I don't know what.  
I hard-coded `TITLE`, `_LENGTH` and `TRACK` outputs to represent a list of 3 tracks:  
Track "A" (#1/00:10)  
Track "B" (#2/00:20)  
Track "C" (#3/00:30)

Loading 3 tracks **exactly** onto Mp3Tag and running the script where I was having the previous issue

 ![imagem](https://community.mp3tag.de/uploads/default/original/3X/6/0/60013f13dbb590a21fa42fff5de3b74084863ac1.png)

Same script, same settings, on 2 selected tracks

 ![imagem](https://community.mp3tag.de/uploads/default/original/3X/f/3/f3a3f719d5a57bd8c82ddf8fe6da0fbb62cc224e.png)  
Only tags for the same number of selected tracks are shown. Track length is now missing.  
Debug file shows all values as they were intended.

Same script, same settings, on a selection of 9 tracks

 ![imagem](https://community.mp3tag.de/uploads/default/original/3X/8/2/82d4b24d2373ef9afbbb7d7c36e8e9853fe2f86e.png)  
Debug file shows all normal. This should not be happening.

Other scripts run perfectly fine; its only on this one (and its many troubleshooting variants) that I'm having trouble.  
I've rebooted my pc, uninstalled/reinstalled MP3Tag -\> same  
Downloaded a fresh v3.27 64-bit copy, unpacked it (did not install), copied the 1 script to its sources folder -\> same result.

I'll try later on a different machine.......

* * *

EDIT: Me being tired was what was wrong. After changing `TITLE` to `TRACKS` that part was solved. But the issue regarding comments still stands.

My apologies.

---

<div class="post-metadata">

### Author: ![rboss](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rboss](https://community.mp3tag.de/u/rboss)
#### Post date: [August 21, 2024, 8:01pm UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645/3 "2024-08-21T20:01:19Z")

</div>

> [@rboss](#):
>
> After changing `TITLE` to `TRACKS` that part was solved

But my tired past self was following some logic, since the [Tag Field Mappings](https://docs.mp3tag.de/mapping/) page does list

 ![imagem](https://community.mp3tag.de/uploads/default/original/3X/8/d/8d61f0c8028badc89f7749c1ebbae49d6a5ac7fd.png)

`TITLE` as a valid tag field available, while the working `TRACKS` internal tag field is not present in the list.  
So the logic was sound, but following a (maybe) outdated source.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [August 22, 2024, 9:14am UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645/4 "2024-08-22T09:14:22Z")

</div>

> [@rboss](#):
>
> After some more tests I came up with the hypothesis that the last line in a `[Parser...]` block must not be a command with a comment, or that command will not run. Having a command without comments or a comment after the last commented command will escape this behavior.
> 
> Can someone reproduce this and validate my theory?

Yes — impressive debugging from your part! Thank you for pointing to this issue. I'll look into fixing that part of the parser (without breaking anything else) and will keep you posted.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [October 2, 2024, 2:13pm UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645/5 "2024-10-02T14:13:30Z")

</div>

This issue is now fixed with [Mp3tag v3.27b](https://community.mp3tag.de/t/455). Thanks again for reporting!

---

<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: [November 1, 2024, 2:14pm UTC](https://community.mp3tag.de/t/comments-on-endif-disable-the-command/65645/6 "2024-11-01T14:14:27Z")

</div>

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