How to get word offset all instances of a string in a chunk of text?

hh hh at hyperhh.de
Thu Aug 30 07:48:23 EDT 2018


> Alex T. wrote:
> 
> put 0 into tOffset
> repeat for each trueWord W in tSource
>    add 1 to tOffset
>    if W = myWord then
>       put tOffset & comma after tOffsetList
>    end if
> end repeat

This is (whether trueWord or word chunks used) probably the fastest
method for an offset counting of one (true)word.

Possibly it is for a large tSource (say 4 MByte) better to use CR
instead of comma as delimiter for the list:
Else, when putting tOffsetList into a field, LC may cut the result
or even hang (LC 9) because the maximum pixel size of a line gets
exceeded.




More information about the use-livecode mailing list