Jump to content

Recommended Posts

Posted

Dim $array[10]

to delete it I just

$array = ""

Lar.

Does that actually free the memory for the array, though? The helpfile says $array = 0 will free it...
Posted

Or to delete one element, just over write it.

Dim $x[3]

$x[0]=1

$x[1]=2

$x[2]=3

How to delete $x[2] ?

$x[2]=""

I think he means make it go away totally.

$x[0] = 3

$x[1] = 2

$x[2] = 1

Now delete $x[1] and you have this:

$x[0] = 3

$x[1] = 1

$x[2] = No longer exists, so it would be out of bounds.

BlueScreen, you have 2 options. One is to either check to make sure the element isn't empty before you act on it, this will allow you to use scriptkitty's solution of just assigning "" to the element. The other is to design some functions and stuff to implement your own container or something.

Posted

10x scriptkitty, but when running "Ubound", it keeps showing 3 elements instead of 2 !

Dim $x [3]
$x[0]=1
$x[1]=2
$x[2]=3

$x[2]=""
msgbox (0,"",Ubound ($x)); Should result 2, no?
  • Administrators
Posted

Does that actually free the memory for the array, though?  The helpfile says $array = 0 will free it...

Assigning anything to the whole array will free it and turn in back into a single value.


 

Posted

Assigning anything to the whole array will free it and turn in back into a single value.

Very good point you make. :whistle:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...