delete array element

Slava Paperno slava at lexiconbridge.com
Mon Jul 4 00:15:11 EDT 2011


Could someone help me translate this entry in the 4.6.2 Dictionary, please?

===
delete variable

Type: command

Syntax:     
delete {local | global | variable} {variableName | arrayIndex}
===

What is the "arrayIndex" here? The index of what array? It seems to be an
alternative to "variableName", but that doesn't make sense.

The same entry in the Dictionary also has this example:

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

When I try to use that command in the Message box, I get an error:

global myVariable; put "A" into myVariable[1]; put "B" into myVariable[2];
delete global myVariable[2]

"Error description: delete: bad variable expression"

I also tried "delete global myVariable[2]" and got this:

"Script compile error: Error description: create: no file name supplied"

What am I doing wrong?

Other than deleting an element, my use of array, including subarrays, is
unproblematic. But my attempts to delete the last element of an array (so
its length is shortened by one) bomb. (I don't mean to put an empty value
into the last element--I do mean to delete the last element so it doesn't
exist.)

Thanks!

Slava






More information about the use-livecode mailing list