2005/12/29 | [dir源码]用 lingo 自己写大小写转化函数!
类别(源码下载) | 评论(2) | 阅读(231) | 发表于 10:38

文章作者:爱伊

 

--例子:

 

--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
0

评论Comments