set myLib to load script file (((path to "cusr" from user domain) & "DEV:LibPool:myLibrary.scpt") as text)
tell application "TextWrangler"
set theTextToChng to selection as text #of window 1 #- insert actions here
set theTextToChng to myLib's changeCase(theTextToChng, "hilo")
set selection to theTextToChng
end tell
(* Inside myLibrary *)
on changeCase(theText, action)
if action = "hi" then
set cmd to "echo " & quoted form of theText & " | tr \"[:lower:]\" \"[:upper:]\""
else if action = "lo" then
set cmd to "echo " & quoted form of theText & " | tr \"[:upper:]\" \"[:lower:]\""
else if action = "hilo" then
set cmd to "PHP -r 'echo ucwords(strtolower(\"" & theText & "\n\"));'"
end if
return (do shell script cmd)
end changeCase