My Bold Script is slow

Björnke von Gierke bvg at mac.com
Sat Feb 9 18:05:02 EST 2002


On Freitag, Februar 8, 2002, at 03:49  Uhr, Terry Vogelaar wrote:

> Hello Björnke,
>
> It took a while before I knew how to handle this, but the resulting 
> script
> is fast and simple. As far as I know, it only works with fields, not 
> with
> selections. I hope you don't mind. If it is important, maybe you can 
> make a
> workaround by copying the selection in an empty field first.
>
> on mouseUp
>   put the htmltext of fld 1 into var1
>   replace "<b>" with "" in var1
>   replace "</b>" with "" in var1
>   set the htmltext of fld 1 to var1
> end mouseUp
>
> Terry

Hey thats a cool solution, but unfortunately it will deselect the text!
As it is not working with the selection it is not applicable for me, 
what is realy regretable, couse that's realy a fast solution.
Anyway, I have found a pretty fast solution myself, and am not longer in 
need of a faster way of removing styles. If anyone else has a similar 
problem, I added the script below:

on mouseUp
   put "bold" into myStyle
   lock screen --this speeds things extremly up!

   repeat with myChar = the second word of the selectedChunk to \
            the fourth word of the selectedChunk
     put the textStyle of char myChar of card field "text" into 
myCurrentStyle
     if myStyle is in myCurrentStyle then
     -- this if statement passes by any non bold chars, minor enhancement

       put myChar into mySecChar
       repeat while the textStyle of char mySecChar+1 of field "text" = \
                    myRepeat and mySecChar < the number of chars in the 
selection
         add one to mySecChar
       end repeat
       -- I persumed that the writing is what's slow, and I was right!
       -- With this loop I gained around 2000-3000%!!!!!!!!!

       delete item itemoffset(myStyle,myRepeat) myRepeat --isn't faster 
then bevore
       set the textstyle of char myChar to mySecChar of field "text" to 
myCurrentStyle
       put mySecChar into myChar
       -- thanks to the loop, I can just bypass many chars, often all of 
the bold-ies,
       -- as they tend to group (these nasty budgers ;-).
     end if
   end repeat
end mouseUp

so if anyone needs a real fast style-remover/adder which doesn't change 
other styles, then feel free to use this one, but please appriciate my 
work on it (I needed almost 3 f*&% weeks! )  and please include a 
"style-script made by BvG" comment into your script.

sincerely yours
Björnke von Gierke




More information about the use-livecode mailing list