Replacing Characters
Dick Kriesel
dick.kriesel at mail.com
Sat Sep 27 04:49:52 EDT 2014
On Sep 27, 2014, at 12:23 AM, JB <sundown at pacifier.com> wrote:
> But there might be a faster way.
Hi, John.
Here's a way that works in under a millisecond on my iMac, and a way to test its speed.
command replace_maybe @rString
repeat with i = 3 to length( rString ) step 3
if char i of rString is "D" then
put "+" into char i of rString
end if
end repeat
end replace_maybe
on mouseUp
local tString, tMilliseconds
repeat 1000 -- strings
put empty into tString
repeat 10000 -- characters
put any char of "abcdef" after tString
end repeat
subtract the long milliseconds from tMilliseconds
replace_maybe tString
add the long milliseconds to tMilliseconds
end repeat
answer "milliseconds per string:" && tMilliseconds / 1000
end mouseUp
How's that, John?
-- Dick
More information about the use-livecode
mailing list