My Bold Script is slow

Björnke von Gierke bvg at
Sat Feb 9 19:27:01 EST 2002

On Sonntag, Februar 10, 2002, at 01:06  Uhr, Ian Summerfield wrote:

> Well I can't take any credit for the superb solution, but I can see it's
> easily modified not to deselect the text:
> on mouseUp
>    put the selectedChunk into rememberChunk
>    put the htmltext of the selectedChunk into var1
>    replace "<b>" with "" in var1
>    replace "</b>" with "" in var1
>    do "select "& rememberChunk
>    set the htmltext of the selection to var1
>    do "select "& rememberChunk
> end mouseUp
> It wouldn't be too hard to rewrite it as a function taking parameters 
> for
> bold, underline, etc.  As a bonus the solution above is now able to 
> work on
> whatever text is selected regardless of which field it's in!

wohoo this works!! thats probably the best (cleanest,fastest) version 
ive seen 'till now, I will certainly trash the other version for this 

> BTW: It's still bad coding practice to use calculations in a loop,  each
> iteration of the loop will cause those calculations to have to be 
> re-done,
> it will also make you code difficult to maintain.  If for any reason in 
> the
> future someone modifies your code to change the selection during one of 
> the
> loop passes then "the fourth word of the selectedChunk" could change 
> it's
> value - spelling disaster.  I got my knuckles wrapped for doing such 
> things
> when I first worked in Apple USA on Applelink Offline!  Take my work 
> for it,
> if you can get into the habit of putting things slightly longer it will 
> be
> more efficient, but safer!
> Put the second word of the selectedChunk into startloop
> Put the fourth word of the selectedChunk into endloop
> repeat with myChar = startloop to endloop
>   -- now it's safe to do things like "select line 1 to 5 of ..."
> End repeat

Well, if you buy me the license for rev ( see above mailing by me on 
that subject), I will happily use variables whenever I define a loop, 
but unfortunately, im bound to the 10 line limit, and I can't define a 
additional variable without using an additional line, so I have to 
produce some more spaghetti-code :(

sincerely yours
björnke von gierke
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2206 bytes
Desc: not available
URL: <>

More information about the Use-livecode mailing list