richmondmathewson at gmail.com
Wed Oct 27 12:50:42 EDT 2010
On 10/27/2010 07:34 PM, Devin Asay wrote:
> On Oct 27, 2010, at 10:21 AM, Alex Adams wrote:
>> Is there a function that I can use to convert a string to title text (the
>> first letter of each word is capitalized)? I can¹t find one in the
>> dictionary. I could write a handler I suppose, but I¹m hoping there is
>> something already available.
> Here's a really basic one I have used. It actually let's you choose between sentence case and title case with an optional argument. But there is no checking for words that shouldn't be capitalized according to English capitalization rules, such as prepositions. But it's a start.
> function capitalize string,allWds
> if allWds is true then
> put number of words in string into limit
> put 1 into limit
> end if
> repeat with i = 1 to limit
> put toUpper(char 1 of word i of string) into char 1 of word i of string
> end repeat
> return string
> end capitalize
Presumably that only works for English ????
More information about the Use-livecode