offset broken?

Peter Haworth pete at lcsql.com
Sat Feb 22 15:21:06 EST 2014


I found it a bit odd too when I discovered it.  I found that I was often
using the chars to skip parameter in a repeat loop and now I usually avoid
it by deleting the characters from the beginning of the string to the
offset each time around the loop.  May or may not work for you depending on
what you are trying to do.


Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Sat, Feb 22, 2014 at 10:32 AM, prothero at earthednet.org <
prothero at earthednet.org> wrote:

> Folks:
> I get it. It seems an odd way to implement it, though. Anyway, a
> clarification in the docs would help the confusion, and the use of the word
> "items" in the docs is definitely confusing.
>
> Another thing that confuses me, as a newbie, is the free interchangeable
> use of "handler" and "script". In my understanding, a "script" is the
> entire collection of handlers within an object. A handler is what comes
> between the "on someName" and the "end someName" or the "function someName"
> and the "end someName". I am still not clear on the limits of how many
> "scripts" in the front scripts and whether the limit applies to "scripts"
> or "handlers".
>
> Minor frustrations all, because i do like livecode and have been feeling
> very productive using it.
>
> Best,
> Bill
> William Prothero
> http://es.earthednet.org
>
>
>
> On Feb 22, 2014, at 10:25 AM, Peter Haworth <pete at lcsql.com> wrote:
>
> > Hi Bill,
> > If you specify a number of characters to skip, the offset that is
> returned
> > is relative to that number, not the start of the string.  So if you
> specify
> > 7 characters to skip and the character you are looking for is the 10th
> > character in the string, you will get (10-7) or 3 as the result.
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
> > Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> > SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
> >
> >
> > On Sat, Feb 22, 2014 at 9:49 AM, prothero at earthednet.org <
> > prothero at earthednet.org> wrote:
> >
> >> Folks:
> >> I think there is something weird about "offset". This occurred on
> version
> >> 6.5 and now on 6.6.
> >>
> >> First off, the documents say:
> >>
> >> "the charsToSkip is a non-negative integer. If you don't specify how
> many
> >> charsToSkip, the offset function does not skip any items and starts at
> the
> >> beginning of the stringToSearch."
> >>
> >> Note the use of the word "items".  Skipping characters vs skipping
> "items"
> >> is a different matter. In the revdocs that are online, the definition of
> >> "characters" to skip is correct.
> >>
> >> But, that's not the end of the story. Offset does not appear to be
> working
> >> correctly anyway.
> >>
> >> If I run the script:
> >>
> >>   put "abcdefgabcccablmnopoq" into theChars
> >>   put offset("c",theChars)
> >>
> >> I get: 3, which is correct
> >>
> >> If I do:
> >>   put "abcdefgabcccablmnopoq" into theChars
> >>   put offset("c",theChars,3)
> >>
> >> I get 7.  ??? What the heck? It looks like it returns (the number of
> >> characters to the search char) - (# to skip).
> >>
> >> But, if I do:
> >>   put "abcdefgabcccablmnopoq" into theChars
> >>   put offset("c",theChars,7)
> >>
> >> I get: 3
> >>
> >> So, something is very wrong with the offset command. I worked around
> this
> >> in a parsing script by always not skipping any characters, then after I
> >> found the first instance, deleting the characters I wanted to skip
> before
> >> the next offset invocation.
> >>
> >> Seems like a bug to me. What do you think? Or is it only my system? Or
> is
> >> the use of the offset function some convoluted logic that's different
> from
> >> most other implementations of an offset function? What do I know? I'm
> new
> >> to Livecode.
> >>
> >> Best,
> >> Bill
> >>
> >>
> >> William Prothero
> >> http://es.earthednet.org
> >>
> >>
> >> _______________________________________________
> >> 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
> >>
> > _______________________________________________
> > 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
>
>
> _______________________________________________
> 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