Interesting wordOffset behavior

Peter Haworth pete at lcsql.com
Mon Dec 3 16:19:28 EST 2012


Thanks Mark.  I knew there must be a logical explanation for it!
Pete
lcSQL Software <http://www.lcsql.com>



On Mon, Dec 3, 2012 at 12:39 PM, Mark Schonewille <
m.schonewille at economy-x-talk.com> wrote:

> Hi Pete,
>
> It will return 0 if you set the wholeMatches to true.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
> KvK: 50277553
>
> Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other colour
> spaces. http://www.color-converter.com
>
> We have time for new software development projects. Contact me for a quote.
>
>
>
>
> On 3 dec 2012, at 21:36, Peter Haworth wrote:
>
> > I'm finding that wordOffset treats comment chars as a word even if they
> > are immediately followed by another character.
> >
> > For example:
> >
> > wordOffset("--","repeat with x=1 to 100 --check something")
> >
> > ...returns 6.  I would have expected it to return zero since there is
> > no occurrence of "--" surrounded by spaces or quotes.
> >
> > To add to the plot:
> >
> > put word 6 of "repeat with x=1 to 100 --check something"
> >
> > ...returns "--check"
> >
> > And:
> >
> > wordOffset("--","repeat with x=1 to 100 -- check something")
> >
> > ...also returns 6 (there's a space between the comment chars and "check"
> in
> > this example).
> >
> > It turns out that this is useful in the context of what I'm doing but
> > whenever I run into what I think is unexpected behavior like this, I'm
> wary
> > of using it in case it's actually a bug that might get fixed at some
> point
> > and break my code.
> >
> > Am I being over cautious?
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
>
>
>
> _______________________________________________
> 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