View Single Post
Old 11-26-2012, 09:40 AM   #11
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ousire View Post
aaha, that did the trick nicely! and thanks to all this, i'm understanding this coding stuff a lot better then trying to force my way through the manual. if i'm understanding right, the commas mark the space as something to be inserted, and without them, the code just assumed the space was extra filler to ignore?
Sort of ...

That template returns the value generated by the strcat function, where "strcat" is programmer-shorthand for "string concatenate". A "string" is a possibly-empty sequence of characters.

A function like strcat takes "arguments", which are "things" that it is supposed to use when it does its job. The "things" are found between the open and close parentheses. A "thing" can be the result of another function, or a constant. Constant strings are characters surrounded by quotes. "Things" must be separated by a comma.

Applying both of these definitions, we see that in the template that works, strcat is to create a single string (its result) from 3 "things": the result from the series_sort() function, the constant ' ' (a single space in quotes), and the result of the template() function (the rest of what you want). The resulting string has all leading and trailing spaces removed, then is passed back to the "user", in this case the plugboard.

So, if there is no series (series_sort() returns nothing), strcat creates a string from the second argument (the constant string) and the third argument (template()). The extra leading space (the second argument) is then removed. If series_sort() returns something then that constant space is in the middle of the result (between the series name and the result of template()), and is not stripped away.

My guess is that this is more information than you wanted. That said, the ex-professor in me is happy to try to satisfy someone's curiosity about how this stuff really works.
Quote:
either way, my problem has been nicely solved, and my library management has been simplified tenfold. thank you for all the help!
You are quite welcome.
chaley is offline   Reply With Quote