Lo script seguente prende la stringa abcdefg e la suddivide in 3 righe: abc def g
Ora, se resto è uguale a 0? succede una cosa strana:
al posto di abcdefg (7caratteri) inseriamo abcdef (6 caratteri) in modo che il resto sia uguale a zero e le righe siano solo2 (array(0) e array (1).
Lo script in questo caso mi crea un terzo array(2) vuoto:
ARRAY(0):abc
ARRAY(1):def
ARRAY(2)
Come mai?
codice:dim testo,maxLen testo_abstract="abcdefg" maxLen=3 lentotale=Len(testo_abstract) righe=Int(lentotale/maxlen) resto=lentotale-(maxLen*righe) For x=0 To righe If testo="" Then testo=Mid(testo_abstract,x+1,maxLen) & "<br>" Else testo=testo & Mid(testo_abstract,(maxLen*x)+1,maxLen) & "<br>" End If Next If resto > 0 Then For y=0 To resto testo=testo & Mid(testo_abstract,(maxLen*(x+y))+1,maxLen) & "<br>" Next End If Dim MioArray MioArray = Split (testo, "<br>", -1, 1) testo="" conta=righe if conta>=0 then response.write("arr1: "&MioArray(0)) RESPONSE.WRITE("<BR>") if conta>=1 then response.write("arr1: "&MioArray(1)) RESPONSE.WRITE("<BR>") if conta>=2 then response.write("arr2: "&MioArray(2)) RESPONSE.WRITE("<BR>") if conta>=3 then response.write("arr3: "&MioArray(3))

Rispondi quotando