IPB

Welcome Guest ( Log In | Register )

> foobar2000 Tech Support Forum Rules

Please read foobar2000 Tech Support Forum Rules before posting and comply with all the points.
Failure to provide all the information pointed out in the above document in your post is considered wasting other people's time and in extreme cases will lead to your topic getting locked without a reply.


See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Description of all the 4 padding functions in the wiki page is not cor
LL25255252
post Aug 28 2013, 22:10
Post #1





Group: Members
Posts: 28
Joined: 4-February 13
Member No.: 106410



http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Title_Formatting_Reference#.24pad.28x.2Clen.29
I think the description as of now is not correct.

Change the description to something like (example):
$pad_right(x,len)
Pads x with spaces up to len characters so that x is aligned to the right.
Go to the top of the page
+Quote Post
db1989
post Aug 29 2013, 08:15
Post #2





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



Not intending to be rude, but rather than asking other people to do it for you, you could register and do it yourself:
http://hydrogenaudio.org/forums/?showtopic=97018
Go to the top of the page
+Quote Post
BenB
post Aug 29 2013, 15:20
Post #3





Group: Members
Posts: 746
Joined: 17-April 12
Member No.: 98921



QUOTE (LL25255252 @ Aug 28 2013, 16:10) *
http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Title_Formatting_Reference#.24pad.28x.2Clen.29
I think the description as of now is not correct.

Change the description to something like (example):
$pad_right(x,len)
Pads x with spaces up to len characters so that x is aligned to the right.

And what exactly is incorrect?

QUOTE
$pad(x,len)
Pads x from the left with spaces to len characters.

$pad_right(x,len)
Pads x from the right with spaces to len characters.

$pad(x,len,char)
Pads x from the left with char to len characters.

$pad_right(x,len,char)
Pads x from the right with char to len characters.


The current descriptions describe how they work, which doesn't always help in explicitly explaining what they do, but your proposed change is ambiguous as to how and how is more important to someone learning title formatting IMNSHO.

The wording of the page is uniform. Each definition lends itself to understanding the other entries. If people edit it every time they misunderstand something, it will become an overly-worded, jumbled mess.

This post has been edited by BenB: Aug 29 2013, 15:24
Go to the top of the page
+Quote Post
Kohlrabi
post Aug 29 2013, 16:50
Post #4





Group: Super Moderator
Posts: 1050
Joined: 12-March 05
From: Kiel, Germany
Member No.: 20561



QUOTE (BenB @ Aug 29 2013, 16:20) *
And what exactly is incorrect?

QUOTE
$pad(x,len)
Pads x from the left with spaces to len characters.

$pad_right(x,len)
Pads x from the right with spaces to len characters.

$pad(x,len,char)
Pads x from the left with char to len characters.

$pad_right(x,len,char)
Pads x from the right with char to len characters.

The problem is that the descriptions are wrong. $pad(x,len) pads from the right (i.e. it adds spaces to the end of x), so that the result has minimum length len (i.e. it's left-aligned), and $pad_right(x,len) pads from the left (i.e. it adds spaces to the beginning of x), so that the result has minimum length len (i.e. it's right-aligned).


--------------------
Ceterum censeo Masterdiskem esse delendam.
Go to the top of the page
+Quote Post
derty2
post Aug 29 2013, 17:45
Post #5





Group: Members
Posts: 581
Joined: 5-June 11
Member No.: 91257



Edit the Wiki and append an example to each item . . . something like this should do the trick:

QUOTE
$pad(x,len)
Pads x from the left with spaces to len characters. Example: $pad(x,3) → "x<space><space>"

$pad_right(x,len)
Pads x from the right with spaces to len characters. Example: $pad_right(x,3) → "<space><space>x"

$pad(x,len,char)
Pads x from the left with char to len characters. Example: $pad(x,3,y) → "xyy"

$pad_right(x,len,char)
Pads x from the right with char to len characters. Example: $pad_right(x,3,y) → "yyx"
Go to the top of the page
+Quote Post
BenB
post Aug 29 2013, 17:46
Post #6





Group: Members
Posts: 746
Joined: 17-April 12
Member No.: 98921



QUOTE (Kohlrabi @ Aug 29 2013, 10:50) *
The problem is that the descriptions are wrong.


Again, let's not confuse how they work and what they do.

$pad(x,len) counts len from the left of x (i.e. how) and adds up to len spaces to the right (i.e. what) of x.

$pad_right(x,len) counts len from the right of x (i.e. how) and adds up to len spaces to the left (i.e. what) of x.

This post has been edited by BenB: Aug 29 2013, 17:57
Go to the top of the page
+Quote Post
foosion
post Aug 29 2013, 18:33
Post #7





Group: FB2K Moderator (Donating)
Posts: 4433
Joined: 24-February 03
Member No.: 5153



I think we could discuss whether the descriptions are wrong or right or we could see this discussion as a sign that the descriptions are at least ambiguous. I therefore agree they should be replaced with a clearer version. My suggestion is this:
QUOTE
$pad(x,len) creates a left-aligned version of the string x. If x is shorter than len characters, the function adds spaces to the right of x to make the result len characters long. Otherwise the function returns x unchanged.


--------------------
http://foosion.foobar2000.org/ - my components for foobar2000
Go to the top of the page
+Quote Post
Kohlrabi
post Aug 30 2013, 13:07
Post #8





Group: Super Moderator
Posts: 1050
Joined: 12-March 05
From: Kiel, Germany
Member No.: 20561



QUOTE (BenB @ Aug 29 2013, 18:46) *
Again, let's not confuse how they work and what they do.
I'm still confused what you are trying to say. Your suggestions are semantically different from the ones in the wiki, the ones I quoted from the wiki are still simply wrong. They don't describe what happens and they don't describe how the functions work.

QUOTE (foosion @ Aug 29 2013, 19:33) *
I think we could discuss whether the descriptions are wrong or right or we could see this discussion as a sign that the descriptions are at least ambiguous. I therefore agree they should be replaced with a clearer version. My suggestion is this:
QUOTE
$pad(x,len) creates a left-aligned version of the string x. If x is shorter than len characters, the function adds spaces to the right of x to make the result len characters long. Otherwise the function returns x unchanged.

I changed the title formatting page entries accordingly. Good suggestion.

This post has been edited by Kohlrabi: Aug 30 2013, 14:57


--------------------
Ceterum censeo Masterdiskem esse delendam.
Go to the top of the page
+Quote Post
derty2
post Aug 30 2013, 17:59
Post #9





Group: Members
Posts: 581
Joined: 5-June 11
Member No.: 91257



I had a look at the Wiki page . . . . and scratched my chin for a while . . . . Sorry, I do not like it!

It is as bad as before but in another sense!
It is unecessarily verbose in a dry technical way and it STILL has an element of confusion ...reminiscent of perplexing legal documents.
The fact of of the matter is that the English language is written from left to right, and every computer user know this.

$pad(x,len) has an obviousness about it which requires nothing more than a few words to describe it.
$pad_right(x,len) if you think about it, is also obvious and relative to the previous function.

IMHO, as a quick clear reference, this would have been a much better change to the Wiki:
QUOTE
$pad(x,len)
Pads x, appending spaces to len characters.  Example: $pad(x,3) → "x<space><space>"

$pad_right(x,len)
Pads x, prefixing spaces to len characters.  Example: $pad_right(x,3) → "<space><space>x"

$pad(x,len,char)
Pads x, appending chars to len characters.  Example: $pad(x,3,y) → "xyy"

$pad_right(x,len,char)
Pads x, prefixing chars to len characters.  Example: $pad_right(x,3,y) → "yyx"

Go to the top of the page
+Quote Post
db1989
post Aug 30 2013, 18:26
Post #10





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



QUOTE (derty2 @ Aug 30 2013, 17:59) *
I had a look at the Wiki page . . . . and scratched my chin for a while . . . . Sorry, I do not like it!
Your opinion has been logged.

QUOTE
It is as bad as before but in another sense!
It is unecessarily verbose in a dry technical way and it STILL has an element of confusion ...reminiscent of perplexing legal documents.
I disagree. I think it makes sure to provide plenty of information so that there is no room for ambiguity.

And I think your suggestions are too brief, do not distinguish between placeholders and words with actual meaning, and do not sufficiently describe the functions for users who do not know the relevant meanings of words like pad.

QUOTE
The fact of of the matter is that the English language is written from left to right, and every computer user know this.
What do computers have to do with it? Language is not an immutable substance. It can, and should, be bent so as to enable the best descriptions and so forth of the subject at hand. If that means there end up being more words than you personally like, then so be it.

Score my vote as being firmly in favour of what is currently on the page, at least if we compare it to these new suggestions.
Go to the top of the page
+Quote Post
derty2
post Aug 30 2013, 18:54
Post #11





Group: Members
Posts: 581
Joined: 5-June 11
Member No.: 91257



>> ...are too brief, do not distinguish between placeholders and words with actual meaning...

I disagree with your assessment. Anybody looking at that page knows what "x" can be ...it is obvious to anybody with half a brain.

>> ...users who do not know the relevant meanings of words like pad.

similar answer.

Can anybody reading this topic tell me something . . .
if you read my edition at the Wiki page would you be left scratching your head wanting more information? (I doubt it very much).
Go to the top of the page
+Quote Post
BenB
post Aug 30 2013, 19:10
Post #12





Group: Members
Posts: 746
Joined: 17-April 12
Member No.: 98921



It is somewhat wordy. It could "shortened" to something like:
QUOTE
Adds spaces to the right of x to make the result len characters long if x is shorter than len characters, otherwise returns x unchanged.


I don't know about this bit:
QUOTE
creates a left-aligned version of the string x

as that isn't entirely accurate. It really depends on where/how it's used. I suppose one could add something like:
QUOTE
Typically used to align text on its left that would otherwise be flush right.


EDIT: left-align isn't a verb, derp


This post has been edited by BenB: Aug 30 2013, 19:18
Go to the top of the page
+Quote Post
LL25255252
post Aug 30 2013, 22:07
Post #13





Group: Members
Posts: 28
Joined: 4-February 13
Member No.: 106410



Score my vote (like @db1989 vote) as being in favor of @Kohlrabi wiki update (@foosion's suggestion) which is currently on the page.

I think that we all agree that the descriptions of these functions could have been shorter and this discussion would not exist if the author of these 4 functions used better names for them.
For example - $pad_right should have been called $pad_left (because it pads spaces from the LEFT of x).

Obviously, what was done can't be reversed...
Go to the top of the page
+Quote Post
derty2
post Aug 31 2013, 06:49
Post #14





Group: Members
Posts: 581
Joined: 5-June 11
Member No.: 91257



LL25255252 - No, I do not agree with your opinion that the author of the function names 'got it wrong' and should have named them 'better'.
The function names translate in a clear literal way if one bothers engaging with nothing more than a drop of logic.

$pad(x...           is self-explanatory; it is saying PAD X.
$pad_right(x..    is self-explanatory; it is saying PAD X TO THE RIGHT.

To anybody with half a brain and just a basic grasp of the English language, this is all plainly obvious.

This whole topic is a storm in a teacup. The only 'mistake' the original author made was using slightly vague wording in his descriptions. My edition solved this by using the words "prefix" and "append". With those words all ambiguity is removed. I also added a example to clarify any doubt. My edition kept to the spirit of the original author .....briefness.

This new edit is verbose pedantic legal-speak and makes a big complex deal out of something simple. It is logic gone mad.
The original edit was short ans sweet, but needed minor update of words used for the definition.
Go to the top of the page
+Quote Post
mobyduck
post Aug 31 2013, 08:55
Post #15





Group: Members
Posts: 573
Joined: 24-April 03
From: Italy
Member No.: 6159



QUOTE
$pad_right should have been called $pad_left
Agreed.

My take:
QUOTE
$pad(x,len[,char])
Pads (adds characters to) the right side of the input string. If len is shorter than the length of x, the function returns x unchanged. Note that the third argument is optional: if it is not provided, a blank space will be used as the default padding character. Examples:
$pad(%tracknumber%,3,-) → "01-"

$pad_right(x,len[,char])
Pads (adds characters to) the left side of the input string. If len is shorter than the length of x, the function returns x unchanged. Note that the third argument is optional: if it is not provided, a blank space will be used as the default padding character. Examples:
$pad_right(%tracknumber%,3,-) → "-01"
Alessandro
Go to the top of the page
+Quote Post
mobyduck
post Aug 31 2013, 10:52
Post #16





Group: Members
Posts: 573
Joined: 24-April 03
From: Italy
Member No.: 6159



I also noticed that specifying a negative len produces weird results. Not sure if it's a bug or the intended behaviour: if the latter perhaps it should be documented.

Alessandro
Go to the top of the page
+Quote Post
Kohlrabi
post Aug 31 2013, 11:54
Post #17





Group: Super Moderator
Posts: 1050
Joined: 12-March 05
From: Kiel, Germany
Member No.: 20561



QUOTE (derty2 @ Aug 31 2013, 07:49) *
This whole topic is a storm in a teacup. The only 'mistake' the original author made was using slightly vague wording in his descriptions.
The original description was simply wrong. Whether the new verbose one should be preferred over a more concise one I will not decide on my own, but the current one is at least correct, which is an improvement.

This post has been edited by Kohlrabi: Aug 31 2013, 11:55


--------------------
Ceterum censeo Masterdiskem esse delendam.
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: 20th September 2014 - 00:44