最近经常见到有人问长英文不自动换行的问题,里面是我写的一个函
来源:岁月联盟
时间:2003-07-11
'-------------------------------------------------
'
' function name: autowrap
'
'
' description : 解决长英文不自动换行的问题
'
' parameters : a_strSourceString :要转换的源字符串
'
' a_intSize , 每行宽度
'
' author: bigeagle
'
' date : 2000/4/17
'
' history: 2000/4/17 : version 1.0
'
'-------------------------------------------------------
function AutoWrap(a_strSourceString , a_intSize)
dim l_strDestString
'如果内容中有回车则退出
'if instr(a_strSourceString , chr(13) + chr(10) ) <> 0 then
' AutoWrap = replace(a_strSourceString , chr(13) + chr(10) , "<br>")
' exit function
'end if
'check if valid parameters
call assert(vartype(a_strSourceString) = 8 , "AutoWrap" , "a_strSourceString must be a string")
call assert(vartype(a_intSize) = 2 , "AutoWrap" , "a_intSize must be a integer")
dim i
if a_intSize >= len(a_strSourceString) then
l_strDestString = a_strSourceString
else
' l_strDestString = left(a_strSourceString , a_intSize)
for i = 1 to len(a_strSourceString) step a_intSize
if instr( i , mid(a_strSourceString , i , a_intSize) , chr(32) ) = 0 _
or instr( i , mid(a_strSourceString , i , a_intSize) , chr(13)+chr(10) )then
l_strDestString = l_strDestString + " " + mid (a_strSourceString , i + 1 , a_intSize)
else
l_strDestString = l_strDestString + mid(a_strSourceString , i + 1 , a_intSize)
end if
next
end if
call print("[AutoWrap:]return value is : '" + l_strDestString + "'")
l_strDestString = replace(l_strDestString , chr(13) + chr(10) , "<br>")
AutoWrap = l_strDestString
end function











