Alain Pastor wrote: > > > Ken Shmidheiser wrote: > >> Basically, I take a text file-- in my case the length of a book-- and >> parse it into an array of individual words for counting, searching for >> multiple appearances and indexing. >> > Perhaps, for better performance in that case, you should preallocate the > memory for a big array inside the Split function. Right before entering > the loop, maybe doing this: > > splitArray(5000) = "" > > I think it would probably be better to modify also the function and the > declaration of the dynamic array to accept only Str31 strings. > I have noticed also that you are calling the Replace function a fair amount of times. This should hurt the speed for very long text files. You can change that rewriting the function maybe like this: begin enum _once _all end enum // This function is used to replace on string with another in a container local fn Replace( @CPtr as ptr,¬ oldSubStr as str255,¬ newSubStr as str255, how as long) dim as long found if oldSubStr[0] = _nil or CPtr.nil& = _nil then exit fn found = fn Munger( CPtr.nil&, 0, @oldSubStr[1], ¬ oldSubStr[0], @newSubStr[1], newSubStr[0] ) Long if how = _all while found > -1 found = fn Munger( CPtr.nil&, found, @oldSubStr[1], ¬ oldSubStr[0], @newSubStr[1], newSubStr[0] ) wend end if end fn You would call the function in ParseContainer like so: // kill all periods in container fn Replace( gC, ".", "", _all ) I remember having troubles in certain configurations with the Munger function used in a similar manner. We tracked that bug in Code Styler with Robert King of the Puns. That's why in that program I use the following which might be suitable in your case with some adaptations: clear local mode local fn FindReplaceAllInHandle( H as handle, search as str15, replace as str255 ) dim count as int dim @ tempH as handle long if fn PtrToHand( @replace[1], tempH, replace[0] ) = _noErr count = fn ReplaceText( H, tempH, search ) DisposeHandle( tempH ) end if end fn 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. Alain