Hi Trenatos,
how long is long? How many adverbs? What is the length of the text (in chars)?
Basically you try to take the text of a field and replace the formatting of the adverbs of the list by changing the htmlText of that field. This is basically a very fast operation.
Some assumptions you make are not right: a field in livecode has no CRLF line delimiter, it is always LF for which CR is a synonym. This is regardless of the source of the text: on Windows, where the line delimiter is CRLF this is transformed on the fly when text is read into a field. But that is not the speed limiting factor.
What you do is to do a replace. I suspect this is what slows things down. Because Livecode has to shuffle a lot of memory to replace the text. A lot faster is to do a new list from your existing list using "put after". Livecode is optimized for that. It only has to append, not split the list insert the new string and reassemble the list.
I just tried to change in a very long text of 5.000 lines with 10.494.999 chars 40.000 occurences of the word "Livecode" to bold and it took about 380 milliseconds. Basically using your approach to work on htmlText.
Now you want to change more than one word. You want to use a list of adverbs and set their style to bold. That may of cours add to the time it takes. Hence my question of how many adverbs.
But I would rather try to speed the things up than to do a non-blocking repeat.
If you could post an example stack with a couple of paragraphs (lines) that are then multiplied after download to a representative length of an average project of yours and a typical list of adverbs in that stack I would have a look at it.
Anyways It takes more words to explain this than to append a sample stack.
I hope Craig is not watching.
It ilustrates what I try to explain above. First click on the button "Fill Field", this generates the text. Then click on button "bold HTML Trenatos". The script for the fill field is in the stack script, the other in button "bold HTML Trenatos". To adapt this to a list of words instead of a single word would be up to you to achieve, you can make it easy by repeating the whole thing for each adverb, maybe you find a faster way.
Kind regards
Bernd
Kind regards
Bernd