Folks, Perhaps I missed it in the docs, but I didn't see where it said the char count returned by offset was measured from the skipped chars count. I do skim, so could have easily missed the fine print.
The way that it's implemented means to get the char position of the found char, you need to do an extra step. But, obviously, it would be crazy to change it and break so much legacy code. Adding info to the docs might protect a newby, but in my case, I did a quick workaround to solve my problem, then pondered why it didn't work the way I expected, later. Thanks for all the discussion. Best, Bill William Prothero http://es.earthednet.org > On Feb 23, 2014, at 10:38 AM, Bob Sneidar <bobsnei...@iotecdigital.com> wrote: > > Nope that is right. It’s “ignoring” the number of characters you are skipping > and treating the character after that as if it were the first character. > > Honestly though, I would have liked to see this work something like the old > dBase function at() where the third argument was the instance of what you > were looking for, and the result was the absolute position of the character > in the search string. AT() would have produced 10 in that case, which is what > I think Bill is after. > > The way this works now it’s the same as saying “delete char 1 to 3 of > theChars” before the offset function, then adding 3 to the result after it. I > don’t really see a need to know what position a character is in after > deleting a number of characters before it, but maybe there would be some > application for it. > > Bob > > >> On Feb 22, 2014, at 09:49 , proth...@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode