Arrays: new and old keys, i

David Bovill david at architex.tv
Thu Sep 11 15:10:30 EDT 2008


Great Trevor - was wandering where I'd read your article!

2008/9/11 Trevor DeVore <lists at mangomultimedia.com>

>
> As for writing a wrapper, what sorts of routines are you looking for? There
> are three features I would really like to see but none of these can really
> be handled by a library. They need to be added to the engine. They are:
>
> 1) Ability to reference an multi-dimensional keys dynamically. Right now we
> have to build the array key reference and then use 'do'.


Yes - that was the first problem I came across. I wanted to write a
recursive function, and since you don't know how deep you will need to go
you have to use "do" which destroys the reason to use arrays 9ie speed) in
the first place. This makes it useless to use as a native data structure for
things like arrays - or at least impossible to create generic libraries for
tree / xml data structures.


> 2) Ability to pass a key of an array by reference. Currently you can't do
> this:
>
> on mouseUp
>    put "Hi There" into theArray[1]["name"]
>    DoSomething theArray[1]
> end mouseUp
>
> command DoSomething @pArrayA
>    ....
> end DoSomething


OK. But "theArray[1]" is just another array - so surely you can do this:

on mouseUp
   put "Hi There" into theArray[1]["name"]
   put theArray[1] into firstArray
   DoSomething firstArray
end mouseUp

command DoSomething @pArrayA
   ....
end DoSomething

  Which I almost prefer for legibility - so that's no biggy for me?

3) Ability to reference elements of an array in the order they were added to
> the array:
>
> put element 5 of theArrayA


Totally. I posted about this earlier. I have to do a lot of scripting to get
around this.



More information about the use-livecode mailing list