text into a tabstopped field

Dar Scott dsc at swcp.com
Sun Aug 20 21:47:55 EDT 2006


On Aug 20, 2006, at 4:21 AM, Mark Smith wrote:

>> The number of items in "a,b,c,d,e,f,g" is 7
>> The number of items in "a,b,c,d,e,f," is 6
>> The number of items in "a,b,c,d,e,," is 6
>> The number of items in "a,,,,,," is 6
>> It is the same with cr's (lines)
>> The trailing comma is not counted as delimiting an empty item.
>
> This is true. And it's also worth noting that this might surprise  
> you when using negative indices.
> So as well as Jims counting examples,
>
> get item -1 of "a,b," --  returns "b"
>
> whereas when getting and setting items by positive index
>
> get item 3 of "a,b," -- returns empty (as you'd expect)
>
> put "a,b," into tLine
> put "d" into item 4 of tLine
> -- leaves tLine as: "a,b,,d"

If you think of the delimiter as being after the data, then this  
makes sense.  The 'tween delimiter notion fails.

The "delimiter after" also allows both representation of a single  
empty item distinct from an empty list of items.

The comma operator doesn't support this notion very well, put a loop  
with 'put it & comma after stuff' does.

On the other hand I think the following is awkward and others might  
feel it make sense:

put item 3 of (1,2 &lf& 3,4)
==>4

It seems the line end should be an item delimiter along with whatever  
the current delimiter character is.

Dar



More information about the use-livecode mailing list