Re: Init Caps Handler
Re: Init Caps Handler
- Subject: Re: Init Caps Handler
- From: Paul Scott <email@hidden>
- Date: Tue, 20 Nov 2007 15:23:34 -0800
On Nov 20, 2007, at 12:57 PM, Oakley Masten wrote:
While I'm at it how about "All Caps" and "No Caps"?
Here's an all AppleScript solution that handles only USASCII
(test code at bottom):
on InitCaps for aString
set s to ""
set ws to 1
repeat with c in (aString as string)
if ((ASCII number c) b $ 32) then
set ws to 1
else
if ws is 1 then
if (((ASCII number c) b % (ASCII number "a")) and
((ASCII number c) b $ (ASCII number "z"))) then
set c to ASCII character ((ASCII number c) - 32)
end if
else if (((ASCII number c) b % (ASCII number "A")) and
((ASCII number c) b $ (ASCII number "Z"))) then
set c to ASCII character ((ASCII number c) + 32)
end if
set ws to 0
end if
set s to s & c
end repeat
return s
end InitCaps
on AllCaps for aString
set s to ""
repeat with c in (aString as string)
if (((ASCII number c) b % (ASCII number "a")) and ((ASCII
number c) b $ (ASCII number "z"))) then
set c to ASCII character ((ASCII number c) - 32)
end if
set s to s & c
end repeat
return s
end AllCaps
on NoCaps for aString
set s to ""
repeat with c in (aString as string)
if (((ASCII number c) b % (ASCII number "A")) and ((ASCII
number c) b $ (ASCII number "Z"))) then
set c to ASCII character ((ASCII number c) + 32)
end if
set s to s & c
end repeat
return s
end NoCaps
set answer to text returned of (display dialog "Enter text" default
answer "")
display dialog ("AllCaps \"" & (AllCaps for answer) & "\"")
display dialog ("NoCaps \"" & (NoCaps for answer) & "\"")
display dialog ("InitCaps \"" & (InitCaps for answer) & "\"")
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden