立即开户的文章按页存到数组infroToArr

‘*************************************************
‘过程名:infroToArr
‘作 用:将要分页的文章按页存到数组
‘参 数:content要分页的文章内容,perLen每页字数(标记字数包含在内)
‘返回值:array(strContent,pageNum)–strContent数组,pageNum页数
‘*************************************************
function infroToArr(content,perLen)
dim pageNum,perStartIndex,lastContent,lastMarkIndex,startMarkIndex,i,j
dim strContent()
perStartIndex=1
pageNum=0
WINNT_CHINESE = (len(“中国”)=2)
if WINNT_CHINESE then
i=0
j=len(content)
‘response.Write(j)
do while perStartIndex<=j
pageNum=pageNum+1
Redim preserve strContent(pageNum)

strContent(i)=mid(content,perStartIndex,perLen)
‘response.Write(strContent(i))
lastMarkIndex=InStrRev(strContent(i), “>”, -1)
startMarkIndex=InStrRev(strContent(i),”<“)
‘ if lastMarkIndex>0 then
‘ strContent(i)=mid(content,perStartIndex,Cint(lastMarkIndex))
‘ perStartIndex=perStartIndex+lastMarkIndex

if startMarkIndex>lastMarkIndex then
dim wlen
wlen=0
while lastMarkIndex=0
wlen=wlen+1
strContent(i)=mid(content,perStartIndex,startMarkIndex-1+wlen)
lastMarkIndex=InStrRev(strContent(i), “>”, -1)
wend
‘while not lastMarkIndex=len(strContent(i))
‘wlen=wlen+1
‘strContent(i)=mid(content,perStartIndex,startMarkIndex-1+wlen)
‘lastMarkIndex=InStrRev(strContent(i), “>”, -1)
‘wend

strContent(i)=mid(content,perStartIndex,startMarkIndex+wlen-1)
perStartIndex=perStartIndex+startMarkIndex+wlen-1

else
templen=len(strContent(i))
if templen <perLen then’监测是否下页是尾页’//且仅有标记
strContent(i)=mid(content,perStartIndex,templen)
exit do
else
temp=right(strContent(i),10)
tempIndex=InStrRev(temp, “&”, -1)
if tempIndex>0 then
strContent(i)=mid(content,perStartIndex,templen-10+tempIndex-1)
perStartIndex=perStartIndex+templen-10+tempIndex-1
else
perStartIndex=perStartIndex+perLen
end if
end if
end if
‘response.Write(strContent(i)&”<br>++++++++++++++”&pageNum&”+++++++++++++++++++++”&perStartIndex&”<br />”)
i=i+1

loop
‘response.Write(perStartIndex)
end if
‘response.Write(strContent(0))
‘for a=0 to i
‘ arr=strContent(a)

‘ next
‘response.Write(“===”&strContent(0)&”1111<br/>”)
infroToArr=array(strContent,UBound(strContent))
end function

« »