Numbering lines
Mark Hsu
mark.h at canelasoftware.com
Fri Oct 26 13:41:38 EDT 2018
I think your issue is where you say “put tcount & j into line tcount of it” — The line X of … call is very slow as it has to count every line from 1 - X.
try this:
local tBuffer
put 1 into tCount
repeat for each line j in pText
put tCount & j & lf after tBuffer
add 1 to tCount
set the thumbpos of scrollbar “filterprog” to tCount
end repeat
delete line -1 of tBuffer
put tBuffer into pText //If you want to update the initial variable with the numbered lines
put tBuffer into field “numberedtext"
- Mark Hsu
> On Oct 26, 2018, at 10:27 AM, David V Glasgow via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> Hello folks
>
> I am doing a content analysis of online chat and messaging. Sometimes very large files, thousands or even hundreds of thousands of messages. I am finding filter and find to be delightfully fast.
>
> However…. Sometimes I want to prefix each line with the line number, and do this:
>
> put 1 into tcount
> repeat for each line j in it
> put tcount & j into line tcount of it
> put tcount + 1 into tcount
> set the thumbpos of scrollbar "filterprog" to tcount
> end repeat
> put it into field “numberedtext”
>
> I use ‘it’ because of a dim memory (superstition? Myth?) from long ago that it is faster than an arbitrarily named variable. Still, the whole process is pretty darned slow. Any brilliant suggestions?
>
>
> Best Wishes,
> David Glasgow
>
>
> <http://www.i-psych.co.uk/> <https://twitter.com/iPsychApps>
>
> <https://twitter.com/iPsychApps> <http://uk.linkedin.com/in/davidvglasgow>
> <http://uk.linkedin.com/in/davidvglasgow>
> _______________________________________________
> 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