Alain Pastor wrote: > This would be slower because the function creates a handle for the > replace string each time it is called, but in your case you are using > only two strings for the replacement (a null string and a space char), > so perhaps you might predefined the two handles in global variables, or > create them entering the ParseContainer function. And then you could > even call ReplaceText in line: > count = fn ReplaceText( [@gC], emptyStrH, "." ) > > I have not tried that, but I think it should work. > Try the following, this should make a difference especially for a very long text: local fn ParseContainer dim as handle repH dim as int count repH = Fn NewHandle(0) Long If repH edit$( 1, _maxInt, _maxInt ) = "Parsing punctuation..." + chr$(13) // kill all periods in container count = fn ReplaceText( [@gC], repH, "." ) // kill all commas in container count = fn ReplaceText( [@gC], repH, "," ) // kill all colons in container count = fn ReplaceText( [@gC], repH, ":" ) // kill all semicolons in container count = fn ReplaceText( [@gC], repH, ";" ) // kill all exclamation points in container count = fn ReplaceText( [@gC], repH, "!" ) // kill all question marks in container count = fn ReplaceText( [@gC], repH, "?" ) // kill all single quotes in container count = fn ReplaceText( [@gC], repH, "'" ) // kill all double dashes in container count = fn ReplaceText( [@gC], repH, "--" ) edit$( 1, _maxInt, _maxInt ) = "Converting tabs,¬ feeds and returns to spaces..." + chr$(13) SetHandleSize( repH, 1 ) Long If Fn MemError = _noErr repH..0`` = _" " // convert tabs to spaces count = fn ReplaceText( [@gC], repH, chr$( 9) ) // convert all line feeds to spaces count = fn ReplaceText( [@gC], repH, chr$(10) ) // convert carriage returns to spaces count = fn ReplaceText( [@gC], repH, chr$(13) ) // Find and replace any occurences of multiple spaces count = fn ReplaceText( [@gC], repH, " " ) End If DisposeHandle( repH ) end if end fn