Re: Convert first char to lower case
Re: Convert first char to lower case
- Subject: Re: Convert first char to lower case
- From: Arthur J Knapp <email@hidden>
- Date: Tue, 08 Jan 2002 10:35:47 -0500
>
Subject: Re: Convert first char to lower case
>
Date: Tue, 8 Jan 2002 02:28:25 +0000
>
From: Nigel Garvey <email@hidden>
>
Olivier Berquin wrote on Mon, 07 Jan 2002 15:20:03 +0100:
>
> I wrote this handler, but I'm not sure that it's very powerfull.
>
> It convert the first character of a var to lower case.
>
'ASCII number' and 'ASCII character' can be quite slow if you have to use
>
them a lot. In AppleScript, it's more convenient to look for the first
>
character in an alphabetical string of the upper-case characters, and to
>
replace it with the same-numbered character from a lower-case string.
Now, I would hate to confuse any newbies out there, but how does this
do for speed? ;-)
property kCharToNum : ({{_:0}} as string)'s text 1 thru -2
on CharToNum(c)
return ((kCharToNum & c) as record)'s _
end CharToNum
on NumToChar(n)
return ({{_:n}} as string)'s item -1
end NumToChar
on LowerChar1(str)
set x to CharToNum(str's item 1)
if (64 < x) and (x < 91) then
return NumToChar(x + 32) & str's text 2 thru -1
else
return str
end if
end LowerChar1
LowerChar1("Hello World") --> "hello World"
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://members.bellatlantic.net/~bswaldie/>
on error number -128
end try
}