Hmmm... great idea. Yeah that might work although a little involved if you need to make this more generic for size.
This works:
lnSecs = SECONDS()
lnCount = 0
n = 0
lnBuffer = 3500
FOR n = 0 TO 9999999999
j = SUBSTR(m.lcString,(n*lnBuffer)+1,lnBuffer)
lnLen = LEN(j)
IF (lnLen < 1)
EXIT
ENDIF
For lnX = 1 To lnLen
lcVal = Substr(m.j,lnX,1)
Endfor
ENDFOR
? "String Splitting: " + TRANSFORM( SECONDS() - lnSecs ) + " " + TRANSFORM(lnCount)
Also playing around with the buffer size - looks like on my machine ~3500 chars seems to work best. Over 5000 it starts slowing down. Under 2,000 it slows down too although not much on that end.
Also interesting - see the `lnCount` in there? If I leave the counter in there times nearly double!
Great thinking. I'll update the blog post (with credit to you)... Thank you!
+++ Rick ---
>
>* 1mb string
>Local lnX, lcString
>lcString = Replicate("1234567890",100000)
>
>lnLength = Len(lcString)
>? "Iterations: " + Transform(lnLength,"9,999,999")
>
> lnSecs = Seconds()
>
>FOR n = 0 TO 999
> j = SUBSTR(m.lcString,(n*1000)+1,1000)
> For lnX = 1 To 1000
> lcVal = Substr(m.j,lnX,1)
> Endfor
>endfor
>
> ? "SUBSTR: " + Transform(Seconds() - lnSecs )
>
>