


'$Filename "t.exe"
'Include "$/inc/RTL32.inc"
 Include "$/inc/console.inc"

#Lookahead

 'String s = Space(2500)
 String s = String (2500,"A")
 
sys i
printl "Press key to begin" : waitkey
While i<1000
   s=Replace s, "A", "A"
   i++
   printl i
Wend
printl "Press key to end" : waitkey



function replace(String t, w, r) As String
   '
   Sys a, b, lw, lr, ls
   string s = t
   '
   ls = len(s)
   lw = Len(w)
   lr = Len(r)
   a = 1
   '  
   Do
      if a>Len s then Exit Do
      a = InStr(a, s, w)
      If a = 0 Then Exit Do
      s = Left(s, a - 1) + r + Mid(s, a + lw)
      a += lr
   End Do
   Return s
End Function

