Peter

Thanks for the suggestions.

> On 25 Mar 2016, at 16:03, Peter TB Brett <peter.br...@livecode.com> wrote:
> 
> On 2016-03-25 08:33, Peter W A Wood wrote:
>> I have an array which contains a second array. (myArray[“numbers”][]).
>> ...
>> automatically change the index of the remaining entries?
> 
> Hi Peter,
> 
> LiveCode arrays are actually dictionaries (more like JavaScript objects than 
> JavaScript arrays).  There aren't currently any push/pop syntax for LiveCode 
> arrays.

Thanks for the confirmation as I wasn’t sure that was the case for all arrays 
due to the existence of the extents function.

> I would recommend two things:
> 
> 1) Arrange your algorithm so that you extract things one-by-one from the 
> _end_ of the numbered array, rather than the start.  This is more efficient!  

It is not possible in this case as the order of the elements is significant. I 
use a different function to remove the last element of the array.

> 
> 2) Alternatively, you can shift everything along, which will be slow:
> 
>   function PopStart @xArray
>      local tLength, tItem, tKey
> 
>      put the number of elements in xArray into tLength
>      if tLength is 0 then return empty
> 
>      put xArray[1] into tItem
> 
>      repeat with tKey = 2 to tLength
>         put xArray[tKey] into xArray[tKey - 1]
>      end repeat
>      delete xArray[tLength]
> 
>      return tItem
>   end PopStart

This is what I am currently having to do but am not too worried yet as I 
believe in the “Getting it working, getting it working correctly, getting 
working quickly approach”.

> I hope that's helpful.

Thanks for the suggestions.

Kind regards

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