Inserting an item beyond item number range bug

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
neville
Posts: 43
Joined: Tue Apr 15, 2008 8:37 am

Inserting an item beyond item number range bug

Post by neville » Tue May 10, 2016 8:39 am

Inserting an item into a line in a field where the line has fewer items has an unexpected (and incorrect) result.
The bug has been confirmed by Quality Control in LC 7.x and 8.0 [http://quality.livecode.com/show_bug.cgi?id=17590], while LC 6.7.x behaves correctly.

Set up a field with contents

Code: Select all

a,b
c,d
Set the mouseUp handler of a button, or msg box command:

Code: Select all

put "x" into item 5 of line 1 of fld 1
The result is

Code: Select all

a,b
c,x,,,d
A standard language should produce an Out of Range error. But an LC programmer surely wants

Code: Select all

a,b,,,x
c,d
that is, empty items to be inserted to fill out the number of items. Producing this result in a standard language would be somewhat awkward, but is the kind of thing LiveCode does with ease.

This is the result if a variable is used rather than a field. It also works correctly on the last line of the field.

As an aside the result of

Code: Select all

put "x" into item -k of <any line> of <any container>
where k > the number of items of that line (or k = 0), is to precede the contents of the container with "x". I'd say this is also unexpected behaviour, but it is consistent and unlikely to be intentional code.

Post Reply

Return to “Talking LiveCode”