-1 as last item problem

Dennis Brown see3d at writeme.com
Sat May 14 09:43:57 EDT 2005


All,

Bug# 976 complains about the problem as a bug --resolved as not a bug  
due to compatibility with HyperCard
Bug#1137 complains about the problem as a lack of proper  
documentation about the quirks of the language. --I voted for this also

It seems that nobody believes that this inconsistency is the desired  
behavior, but because HyperCard did it this way, that is the final  
answer.  This means that item or line delimiters do not go between  
things, but after things.  This is an important point.  The fact that  
the last item delimiter is left off a returned list is inconsistent.   
This leads to confusion and a loss of significant information when  
you have trailing empty items.  Therefore the bug is that a list with  
a trailing empty item needs to preserve the trailing delimiter when  
returned with a item x to -y spec.

I posted Bug#2838: Subject: Trailing delimiter needs to be preserved  
for trailing empty items

> Many programmers have been tripped up by this bug, and it is likely  
> that many scripts are producing faulty results today because of  
> this bug.
>
> Item or line delimiters do not go between things, but after  
> things.  This is an important point to remember.  The fact that the  
> last item delimiter is left off a returned list is inconsistent in  
> the case of an empty item.  This leads to confusion and a loss of  
> significant information when you have lists with trailing empty  
> items.  Trailing empty items can be by design, or due to a chunk  
> specification on a list with embedded empty items.
>
> The fix for this bug is that a list with a trailing empty item  
> needs to preserve the trailing delimiter when returned with a chunk  
> spec.  The resulting behavior will be:  The last item on a list is  
> delimited by a trailing item, or if the last item is empty, the  
> item delimiter.
>
> Without this bug fix, the number of items in a list are changed by  
> removing one item if the last item is empty.  For instance:
>
> get "1,2,3,,,," --a 6 item list with 3 empty items at the end
> get item 1 to -1 of it  --get all the items of it has left off one  
> item, list is now 5 items
> get item 1 to (number of items of it) --get all the items of it has  
> left off one item, list is now 4 items
> get item 1 to -1 of it --get all the items of it has left off one  
> item, list is now 3 items

Dennis


On May 14, 2005, at 1:54 AM, Ken Ray wrote:

> On 5/13/05 8:08 PM, "Dennis Brown" <see3d at writeme.com> wrote:
>
>
>> put item 1 to -1 of line 1 of data
>>
>> I get this:
>>
>> 1,ABT,N,510,,Y
>> 3,AMT,N,836,
>> 22,AL,N,132,F,Y
>>
>> Notice the missing last comma on the second line.
>>
>
> Yes, I've run into that as well, and now I add a check to see if  
> the last
> char on the line is a comma or not before I ask for the last item  
> on the
> line.
>
>
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list