• Replace the
     Code:
      $x = 1
      While $x <= Len($)
    ...
        $x=$x+1
      Loop
    

    by
     Code:
      For $x = 1 to Len($)
    ...
      ;Next
    
  • Name your most used variable $