Delete an Array Entry?

Dave dave at looktowindward.com
Fri Mar 2 06:57:12 EST 2007


On 1 Mar 2007, at 19:02, J. Landman Gay wrote:

> Dave wrote:
>
>> When I read the part quoted above in the documentation I thought  
>> for a moment that myArray[17] was some special usage and wasted  
>> times checking that it worked the way I thought it worked. There  
>> is really no point in describing the RunRev type of Array in these  
>> terms since there is no element 17 or any other numeric index.
>
> Under "delete variable", the docs say: "The arrayIndex is a key of  
> an array variable. If an arrayIndex is specified instead of a  
> variable name, the delete variable command removes that element of  
> the array, without deleting the rest of the elements in the array."
>
> It seems pretty clear that the delete command will remove an array  
> element with the key you specify. That's how associative arrays work.

The Documentation says:

delete global myArray[17] -- removes 17th element of that array

Does this delete the 17th element of the array? No (except if "17"  
just happens to be at position 17). Therefore it's wrong. It makes no  
sense at all to talk about numeric values to "index" into a RunRev  
based array. There is really no such thing as the 17th (or any other  
index) in an RunRev array.

The documentation is unclear. It should read:

delete global myArray[17] -- removes the array element whose key is  
"17".

note: the use of 17 here does not refer to a numeric index, but  
rather to a key that is used to look up the element in the array. It  
is possible to use the array in a similar fashion to the more  
traditional array found in languages such as C and Pascal since  
RunRev converts the numeric value to a string automatically.

Or something like that!

>> Whoever wrote the documentation didn't understand how Arrays in  
>> RunRev work.
>
> That would be hard to believe. Jeanne DeVoto, who wrote most of the  
> documentation, is one of the foremost documentation experts on  
> xtalk scripting, starting with HyperCard, where she was one of the  
> authors of the definitive reference book for that program. She has  
> been working with the language for 20 years, and I'm certain she  
> understands how arrays work in Revolution. But if you haven't  
> worked much with associative arrays, I can see how it could be  
> confusing.

Well he should have known better then!

Have a great weekend - I know I will!
All the Best
Dave






More information about the use-livecode mailing list