[dir源码]用 lingo 自己写大小写转化函数!

      源码下载 2005-12-29 10:38:00

文章作者:爱伊

 

--例子:

 

--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
标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}