BlueScreen 0 Posted March 11, 2004 Hey, I have forgotten how to delete an array element... Share this post Link to post Share on other sites
Valik 478 Posted March 11, 2004 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... Share this post Link to post Share on other sites
BlueScreen 0 Posted March 11, 2004 10x Larry, but is there a possibility to delete an element?Dim $x[3]$x[0]=1$x[1]=2$x[2]=3How to delete $x[2] ? Share this post Link to post Share on other sites
scriptkitty 1 Posted March 11, 2004 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]="" AutoIt3, the MACGYVER Pocket Knife for computers. Share this post Link to post Share on other sites
Valik 478 Posted March 11, 2004 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. Share this post Link to post Share on other sites
BlueScreen 0 Posted March 11, 2004 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? Share this post Link to post Share on other sites
BlueScreen 0 Posted March 11, 2004 10x, Valik, You understood me. I wan't to modify the size of an array dynamically by deleting an element. Is it possible? Share this post Link to post Share on other sites
Jon 1,009 Posted March 11, 2004 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. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
BlueScreen 0 Posted March 11, 2004 OK. So I'll overwrite the array with the new params. 10x everybody... Share this post Link to post Share on other sites
Valik 478 Posted March 11, 2004 Assigning anything to the whole array will free it and turn in back into a single value.Very good point you make. Share this post Link to post Share on other sites