Delete an Array Entry?
ambassador at fourthworld.com
Thu Mar 1 10:17:19 CST 2007
>>> delete global myArray
> does not delete the 17th element, unless the key "17" just happens to
> the 17th element. The documentation is confusing on this point. Also
> the whole name "Array" for this datatype is confusing, a better name
> would be "table", since it doesn't behave like an array at all.
It behaves perfectly well as the associative array it is.
True, most programming languages focus on numerically indexed arrays, so
unless you're familiar with associative arrays Rev's implementation can
be confusing at first.
But the flexibility of associative arrays makes them well suited for a
much broader range of tasks than numeric arrays, since the keys aren't
limited to numbers but can be any string.
It might be helpful if Rev also supported numeric arrays, but in my own
experience I've not found a true need for them that associative arrays
And having one type of array that does it all means there's only one
rule to remember: they key is a string.
If that string happens to be a number, you can use it pretty much like
you would use a numeric array:
repeat with i = 1 to 10
put someData() into MyArray[i]
But being a string, you can also use non-numeric keys just as easily:
repeat for each item tUser in "Dave,Ken,Richard"
put SomeData() into MyArray[tUser]
Managing Editor, revJournal
Rev tips, tutorials and more: http://www.revJournal.com
More information about the use-livecode