IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Unwanted empty line using if condition, if cond is false nothing should happen
LosMintos
post Apr 5 2011, 13:41
Post #1


Member


Group: Full Members
Posts: 88
Joined: 23-September 08
Member No.: 7617
Mp3tag Version: 2.51



Hi,

the export configuration
QUELLTEXT
$loop(%_workingdir%)$if(%year%,%year%,)
$loopend()

should write %year% to a file but do nothing if %year% is false, e.g. no year tag exists. In fact, an empty line is written to the file in case of a non existing year tag.

Any suggestions how to avoid or remove the empty line?
Go to the top of the page
 
+Quote Post
DetlevD
post Apr 5 2011, 14:06
Post #2


Member


Group: Full Members
Posts: 4810
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.61d



QUOTE (LosMintos @ Apr 5 2011, 14:41) *
... In fact, an empty line is written to the file in case of a non existing year tag. Any suggestions how to avoid or remove the empty line?

You have detected a well known design quirk of the Mp3tag export scripting language.
Because Mp3tag 'uses even the paper on which the script is written as significant code content', will say, this is not a format free scripting language.
It is not possible to write a zero byte file.

If you want to prevent unwanted blank lines you have to code the script into a single stream line and force needed linebreaks by dedicated $char(13)$char(10) sequence.

You can try to code (only one line) ...
CODE
$filename('file.txt',ANSI)$loop(%_workingdir%)$if(%year%,%year%$char(13)$char(10),)$loopend()


But I expect it will not work absolutely satisfying, because even this one line is delimited by the EOL character sequence CRLF in the script file, what is the 'paper'.
And because even this 'paper related' EOL is significant in a Mp3tag export script, there will be created an empty line in the output file.
In my opinion this is a worse design quirk.

DD.20110405.1507.CEST

This post has been edited by DetlevD: Apr 6 2011, 04:25


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
LosMintos
post Apr 5 2011, 22:04
Post #3


Member


Group: Full Members
Posts: 88
Joined: 23-September 08
Member No.: 7617
Mp3tag Version: 2.51



Your answer came amazingly fast and precise! :-)

ZITAT(DetlevD @ Apr 5 2011, 15:06) *
You have detected a well known design quirk of the Mp3tag export scripting language.
Oh, well, did you notice, that I wrote $loop()$if() in a single line? ;-))

ZITAT(DetlevD @ Apr 5 2011, 15:06) *
If you want to prevent unwanted blank lines you have to code the script into a single stream line and force needed linebreaks by dedicated $char(13)$char(10) sequence.
This seems to work well! Is there a not-so-experienced-user friendly table somewhere listing all theses char-values and their meanings? From what I found, I would not guessed, that (Unicode hex values?) 13 and 10 produce a line break.

Here's my working example, exporting ReplayGain's according to year (so far without any valid trend ;-))

QUELLTEXT
$filename(ReplayGainStats.dat,utf-8)# ReplayGain values and year of %_workingdir% at %_date%
#
# YEAR, REPLAYGAIN_ALBUM_GAIN, REPLAYGAIN_ALBUM_PEAK, REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK
# -, dB, -, dB
$loop(%_workingdir%)$if(%year%,$left(%YEAR%,4)$char(9)$cutRight(%REPLAYGAIN_ALBUM_GAIN%,3)$char(9)%REPLAYGAIN_ALBUM_PEAK%$char(9)$cutRight(%REPLAYGAIN_TRACK_GAIN%,3)$char(9)%REPLAYGAIN_TRACK_PEAK%$char(13)$char(10),)$loopend()


ZITAT(DetlevD @ Apr 5 2011, 15:06) *
In my opinion this is a worse design quirk.
That could be avoided with a comment symbol. In TeX and LaTeX % works as comment and one can avoid unwanted linebreaks by putting % at a line's end:
QUELLTEXT
$loop()%
   $if()%
$loopend()
This way one ccould write readable sources and produce desired output.
Go to the top of the page
 
+Quote Post
DetlevD
post Apr 6 2011, 05:39
Post #4


Member


Group: Full Members
Posts: 4810
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.61d



QUOTE (LosMintos @ Apr 5 2011, 23:04) *
... This seems to work well! ...

Did you realize the one additional blank line at end oif the output file?

QUOTE (LosMintos @ Apr 5 2011, 23:04) *
... Is there a not-so-experienced-user friendly table somewhere listing all theses char-values and their meanings? From what I found, I would not guessed, that (Unicode hex values?) 13 and 10 produce a line break. ...

The Mp3tag help manual contains a small description for the function $char(), which states, that it can create any Unicode character. Well ... I hope so ... did not checked it ... $char(0) would be of interest.

Since historical times (I was a child of about ten years old and did not know anything about computers) there are a few special characters, which have the meaning of control characters to manipulate a printer's behaviour, for example 'Carriage Return' (13) or 'Line Feed' (10) and even 'Form Feed' (12) or the 'Bell' (7) or the 'Horizontal Tabulator' (9) or the 'Space' (32) and others.
The first 32 characters in the ASCII character table are reserved for control characters.
See section ASCII control characters in http://en.wikipedia.org/wiki/ASCII

QUOTE (LosMintos @ Apr 5 2011, 23:04) *
... Here's my working example, exporting ReplayGain's according to year (so far without any valid trend ;-)) ...

Interesting ... just a few days ago I discovered that the encoder LAME 3.98.4 has made a step forward to work more precisely than its ancestors regarding its own calculation of the replay gain value.
I have recoded some of my music files with my LAMEO optimizer to get a precision now of up to -0.1dB from the maximum scale limit 1.0, which means 0dB.

What can your report tell me? ReplayGain of a song in relation to year?

Back to the problem ... how to avoid unwanted line feeds in Mp3tag report files?
It is too hard for the normal standard user to code all functions and text and so on into one endless stream line. This is far away from practical usage.

Other scripting languages have dedicated constants for characters, which indicate the End Of Line, even for the usage in different systems like @CR (Apple) or @LF (UNIX) or @CRLF (MSDOS/Windows).

Beside there are already some reserved dedicated characters in Mp3tag scripting language: Round and Square Brackets, the Comma, the Single Apostrophe, the Dollar symbol, the Percent symbol, you have proposed to use one special reserved character (maybe a '#' or a '!' or a '=' or whatever) to direct the script parser, where to suppress a 'paper related' LineFeed to not put it into the output text resp. where to take a 'paper related' LineFeed as significant and let it go into the output text.

This could be a (crippled) way to go for Mp3tag without too much changes in the existing parser.
So one have to code the linefeed suppressor at the end of almost all lines in a mte script (... depends on the script).
QUOTE (LosMintos @ Apr 5 2011, 23:04) *
... This way one could write readable sources and produce desired output.


DD.20110406.0640.CEST

This post has been edited by DetlevD: Apr 6 2011, 09:35


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
LosMintos
post Apr 6 2011, 18:23
Post #5


Member


Group: Full Members
Posts: 88
Joined: 23-September 08
Member No.: 7617
Mp3tag Version: 2.51



ZITAT(DetlevD @ Apr 6 2011, 06:39) *
Did you realize the one additional blank line at end oif the output file?
Yes, I know ... no problem for me.

ZITAT(DetlevD @ Apr 6 2011, 06:39) *
The Mp3tag help manual contains a small description for the function $char(), which states, that it can create any Unicode character. Well ... I hope so ... did not checked it ... $char(0) would be of interest.
Good to know: it requires decimal number as input. And then the user is left alone ;-). Foobar http://wiki.hydrogenaudio.org/index.php?ti...#.24char.28x.29 links to this site http://www.fileformat.info/info/unicode/char/search.htm. Very nice.

ZITAT(DetlevD @ Apr 6 2011, 06:39) *
Since historical times (I was a child of about ten years old and did not know anything about computers) there are a few special characters, which have the meaning of control characters to manipulate a printer's behaviour, for example 'Carriage Return' (13) or 'Line Feed' (10) and even 'Form Feed' (12) or the 'Bell' (7) or the 'Horizontal Tabulator' (9) or the 'Space' (32) and others.
I didn't search for ASCII as unicode is required. The table at wikipedia is very helpful! The first "letter" I was searching for, long time ago, was the space, $char(32). I can't remember for what purpose ...

ZITAT(DetlevD @ Apr 6 2011, 06:39) *
What can your report tell me? ReplayGain of a song in relation to year?
I guess you're familiar with the so called loudness war. I had the wild guess, that ReplayGain should correlate somehow with the date of production. I'm afraid I have not enough music files to prove that rolleyes.gif laugh.gif (I don't see a definite trend in my data. Let me know and I will upload the figures here). BTW, foobar just implemented libebur128 for scanning replay gains.

ZITAT(DetlevD @ Apr 6 2011, 06:39) *
Back to the problem ... how to avoid unwanted line feeds in Mp3tag report files?
For the moment for my personal use, I can put code, where no linebreak is allowed, in a single line of *.mte.

On the other hand, a comment-character making code after it "invisible" for the parser, would be very handy. Than I'll probably understand my mte-scripts written years ago. book.gif

ZITAT(DetlevD @ Apr 6 2011, 06:39) *
So one have to code the linefeed suppressor at the end of almost all lines in a mte script (... depends on the script).
I could accept that.
Go to the top of the page
 
+Quote Post
DetlevD
post Apr 6 2011, 18:43
Post #6


Member


Group: Full Members
Posts: 4810
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.61d



QUOTE (LosMintos @ Apr 6 2011, 19:23) *
... Good to know: it requires decimal number as input. And then the user is left alone ;-). ...

Do not use a web site, which wants to download something to be run on your PC to identify something on your PC.
I would recommend to use the one and only original resources at http://www.unicode.org/ucd/

QUOTE (LosMintos @ Apr 6 2011, 19:23) *
... I didn't search for ASCII as unicode is required. ...

The Unicode 'table' starts with all the single-byte characters from the origin ASCII table, then including the rest of the ANSI table, then following many other multi-byte characters given the full Unicode world.

QUOTE (LosMintos @ Apr 6 2011, 19:23) *
... I guess you're familiar with the so called loudness war. I had the wild guess, that ReplayGain should correlate somehow with the date of production. I'm afraid I have not enough music files to prove that rolleyes.gif laugh.gif (I don't see a definite trend in my data. Let me know and I will upload the figures here). BTW, foobar just implemented libebur128 for scanning replay gains. ...

Sounds interesting.

DD.20110406.1944.CEST


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
LosMintos
post Apr 6 2011, 22:57
Post #7


Member


Group: Full Members
Posts: 88
Joined: 23-September 08
Member No.: 7617
Mp3tag Version: 2.51



ZITAT(DetlevD @ Apr 6 2011, 19:43) *
Sounds interesting.
Well ...
Attached Image

Attached Image

Attached Image

Attached Image


Without any comment ...
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 1st August 2014 - 12:50