Skip to main content
Topic: $len() - Apparent anomaly (Read 420 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

$len() - Apparent anomaly

Noted this behavior of the $len() function:

If a field (say, %comment%) contains only one character, $len(%comment%) result is 1 - as expected.
However, if that same field is empty, $len(%comment%) result is also 1 - shouldn't it be 0?

Am I missing something?

Re: $len() - Apparent anomaly

Reply #1
%comment% for empty comment field returns "?" and its length is 1 character. You can use $len([%comment%]) to get zero length for missing fields.

Re: $len() - Apparent anomaly

Reply #2
%comment% for empty comment field returns "?" and its length is 1 character. You can use $len([%comment%]) to get zero length for missing fields.
Interesting.

Noted however that the result of the suggested expression yields 0 for some empty COMMENT fields and 1 for most.
In fact, to experiment, removed the Comment field of a track whose result was 0 and then it turned to 1 - strange.

Re: $len() - Apparent anomaly

Reply #3
Maybe the correct function is $len($meta(comment)) ? I suppose this differs from %comment% in such manner, that $meta() should always return raw value of the invoked field. Please check it and report back if I was right.

Re: $len() - Apparent anomaly

Reply #4
I think the reason is:
When comment field is present but empty then %comment% is "" and $len(%comment%) is 0.
When comment field is absent then %comment% is "?" and $len(%comment%) is 1.

Re: $len() - Apparent anomaly

Reply #5
You can use Media Library Search to find all files that have a comment field if you want to do some experimenting. Search query "NOT comment MISSING" will list the tracks that have the field.

Re: $len() - Apparent anomaly

Reply #6
Maybe the correct function is $len($meta(comment)) ? I suppose this differs from %comment% in such manner, that $meta() should always return raw value of the invoked field. Please check it and report back if I was right.
@EpicForever: Fine. That expression gives the result I was trying to obtain.
@lvqcl + @Case: Even after years, there's always something to learn about Titleformatting.

 
SimplePortal 1.0.0 RC1 © 2008-2019