Comments on "Endif" disable the command

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

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

Endif		 ##_ (If "string")

and have done so for several years.

Today I came across this error
imagem

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:

# 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

# 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?

1 Like

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

Same script, same settings, on 2 selected tracks


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


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.

But my tired past self was following some logic, since the Tag Field Mappings page does list

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.

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.

This issue is now fixed with Mp3tag v3.27b. Thanks again for reporting!

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