ANN: Remove double spaces--plugin

Mark Smith mark at maseurope.net
Mon Dec 5 00:54:15 EST 2005


'The replaceText function is not as fast as the Replace command'

That is certainly true.

in the code below, using the more complicated (in terms of code)  
replace function takes 20ish milliseconds, whereas the replaceText  
version (commented out) takes about 200.



on mouseUp
   repeat 10000 -- set up some text with varying numbers of spaces
     add 1 to c
     put "xxxx yyy" into tLine
     repeat random(10)
       put space after tLine
     end repeat
     put "zzzz." after tLine
     put tLine & cr after tList
   end repeat
   put tList into fld 1

   put fld 1 into tText

   put the millisecs into st
   repeat until doubleSpace = 0
     put offset("  ",tText) into doubleSpace
     if doubleSpace > 0 then replace "  " with " " in tText
   end repeat
   put the millisecs - st
   put tText into fld 1

--  put the millisecs into st
--  put replaceText(tText," +"," ") into tText
--  put the millisecs - st
--  put tText into fld 1

end mouseUp

Mark



More information about the use-livecode mailing list