Replacing Characters
JB
sundown at pacifier.com
Sat Sep 27 06:25:12 EDT 2014
Hi Dick,
That is really nice! Thank you.
It works great.
John Balgenorth
On Sep 27, 2014, at 1:49 AM, Dick Kriesel <dick.kriesel at mail.com> wrote:
> 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
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list