文章作者:爱伊
--例子:
--put str_to_uppercase("Happy New Year To You!")
-- "HAPPY NEW YEAR TO YOU!"
--put str_to_lowercase("Happy New Year To You!")
-- "happy new year to you!"
----------------------------------------------------------------
--函数:str_to_uppercase()
--将指定 字符串转换成大写
on str_to_uppercase str
repeat with i=1 to str.length
str_num=chartonum(str.char[i])
upper_num=chartonum(str.char[i])-32
if numtochar(str_num)=numtochar(upper_num) then
uppered=uppered&numtochar(upper_num)
else
uppered=uppered&numtochar(str_num)
end if
end repeat
return uppered
end
----------------------------------------------------------------
--函数:str_to_uppercase()
--将指定 字符串转换成小写
on str_to_lowercase str
repeat with i=1 to str.length
str_num=chartonum(str.char[i])
lower_num=chartonum(str.char[i])+32
if numtochar(str_num)=numtochar(lower_num) then
lowered=lowered&numtochar(lower_num)
else
lowered=lowered&numtochar(str_num)
end if
end repeat
return lowered
end