I have an array which contains a second array. (myArray[“numbers”][]). The 
numbers array is a traditional array with elements 1..n. I want to remove the 
first element of the numbers array and shuffle all the others up. Is there a 
simple way of doing this in LiveCode (equivalent to the shift() function in 
JavaScript)?

I looked in the dictionary and found delete <variable> but couldn't get it to 
work, perhaps because I am trying to do this in a function that takes the array 
as an argument.

The essence of the function is:

function shift @pList
  local tItem
  put pList[“numbers”][1] into tItem
  delete pList[“numbers”] 1                                     ## Is this the 
correct syntax?
  return tItem
end shift

If I can get delete to remove the first element of the array, will it 
automatically change the index of the remaining entries?

Thanks in advance.

Peter
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to