Interesting wordOffset behavior
Peter M. Brigham
pmbrig at gmail.com
Tue Dec 4 08:43:59 EST 2012
Ah! Caught again by not using parens. Evaluation order is one of the things that I miss sometimes.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
On Dec 4, 2012, at 5:33 AM, Alex Tweedly wrote:
> try
>
> put word 2 of ("one"& tab& "two"& tab& "three")
>
> What you are getting is
> word 2 of "one"
> followed by
> tab& "two"& tab& "three"
>
>
> -- Alex.
>
>
>
> On 04/12/2012 03:34, Peter M. Brigham wrote:
>> Yeah, it doesn't really behave properly. If you do
>> put word 2 of "one"& tab& "two"& tab& "three"
>> you get
>> <tab>two<tab>three
>> and
>> put word 2 of "one"& cr& "two"& cr& "three"
>> gives you
>> <cr>two<cr>three
>>
>> It really should consider any white space as a word delimiter. Sigh. Probably Richard Gaskin can tell us the history behind this, clearly a leftover from HC. Meanwhile you can roll your own:
>>
>> function whichWord tString, wordNbr
>> replace cr with space in tString
>> replace tab with space in tString
>> return word wordNbr of tString
>> end whichWord
>>
>> -- Peter
>>
>> Peter M. Brigham
>> pmbrig at gmail.com
>> http://home.comcast.net/~pmbrig
>>
>>
>> On Dec 3, 2012, at 9:28 PM, Robert Sneidar wrote:
>>
>>> Wordoffset returns space delimited data.
>>>
>>> Bob
>>>
>>>
>>> On Dec 3, 2012, at 10:36 AM, 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
>>>
>>> _______________________________________________
>>> 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