I'm a big advocate of clean functions, and I just want to point out that this is really nicely done: clear, compact, efficient, documented, and the function name itself perfectly describes what it does.
Really nice! On Wed, Dec 19, 2012 at 4:33 PM, Peter M. Brigham <pmb...@gmail.com> wrote: > function offsets str,container,includeOverlaps > -- returns a comma-delimited list of all the offsets of str in container > -- third param is optional: > -- offsets("xx","xxxxxx") returns "1,3,5" not "1,2,3,4,5" > -- ie, by default, overlapping offsets are not counted > -- if you want overlapping offsets then pass "true" in 3rd param > -- returns 0 if str is not in container > if str is not in container then return 0 > if includeOverlaps = empty then put false into includeOverlaps > put empty into offsetList > put 0 into startPoint > repeat > put offset(str,container,startPoint) into thisOffset > if thisOffset = 0 then exit repeat > add thisOffset to startPoint > put startPoint & comma after offsetList > if not includeOverlaps then > add length(str)-1 to startPoint > end if > end repeat > return item 1 to -1 of offsetList -- delete trailing comma > end offsets > > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode