Delete line, row, record ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Delete line, row, record ?

Post by dunbarx » Tue Dec 08, 2015 5:31 pm

In the code you give you know that theArray[15] has nothing
in it.
?? The array name is "tenTimes".

It has "150"

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Delete line, row, record ?

Post by jacque » Tue Dec 08, 2015 8:22 pm

RossG wrote:A curiousity: seems that LC accesses arrays in a rather odd
DOS way i.e. in DOS if you highlight ten file to delete it will first
delete file 1 then file 10, file 9 etc. down to file 2.

Also note that deleted variables don't leave a blank line and
the remaining entries in the array keep their original index numbers
so the number of variables in the array can't be used to ascertain
the next index for adding a new variable.
LC arrays are associative and have no default order. If the script requires a particular order, sort the keys before operating on them and you'll get what you want. In this case, it sounds like you want to sort numeric.

A deleted array key does not replace itself, as you've found. If you want to retain the key for future use, put empty into its content rather than removing the entire key.

Numeric arrays can be queried to get the highest numbered key with "the extents".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply