Failing to understand the oddities of the "line" chunk

Geoff Canyon gcanyon at
Sat Mar 17 16:31:48 EDT 2012

This seems wrong to me. Regardless of how the engine interprets a chunk
expression, a command of the form put <something> into <some chunk> should
result in <some chunk> containing <something> So the fact that you are
putting "b" into something should result in that thing being "b," where
here the result is "ba" further, there's the fact that after the command,
the chunk is still empty. So:

 put "a" & cr into t;put "b" into line 2 to -1 of t;put line 2 to -1 of t
is empty

puts true. I did a quick check to take the negative line number out of
this. If you have a field with contents:




then put line 2 to 1 of fld 1

puts empty, and put "x" into line 2 to 1 of fld 1

results in line 1 of the field being "xa"

again, this feels wrong. "line 2 to 1" of something should be an error. I
can see the value of having it return empty when you are getting it, but
putting something into it results in bad behavior.

Another way of addressing this would be to say that chunk expressions
always understand and follow proper order. So "line 2 to 1" would be the
same as "line 1 to 2" Under that scenario, put "x" into line 2 to 1 of fld
1 would result in the field containing:



and the original problem:

put "a" & CR into t; put "b" into line 2 to -1 of t; put t

would put


which seems like a much more reasonable (and predictable) outcome.


On Sat, Mar 17, 2012 at 11:33 AM, J. Landman Gay
<jacque at>wrote:

> On 3/17/12 8:16 AM, Alex Tweedly wrote:
>> This code
>>> put "a" & CR into t; put "b" into line 2 of t; put t
>> produces (as I would expect)
>>> a
>>> b
>> BUT
>>> put "a" & CR into t; put "b" into line 2 to -1 of t; put t
>> produces
>>> ba
>> Why should adding the "to -1" change this to put the new data before
>> what was there before ?
> It's because of how the engine ignores trailing delimiters. The variable t
> contains only one line, so "line 2 to -1" evaluates to "line 2 to 1".
> --
> Jacqueline Landman Gay         |     jacque at
> HyperActive Software           |
> ______________________________**_________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

More information about the Use-livecode mailing list