BlueScreen Posted March 11, 2004 Share Posted March 11, 2004 Hey, I have forgotten how to delete an array element... Link to comment Share on other sites More sharing options...
Valik Posted March 11, 2004 Share 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... Link to comment Share on other sites More sharing options...
BlueScreen Posted March 11, 2004 Author Share 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] ? Link to comment Share on other sites More sharing options...
scriptkitty Posted March 11, 2004 Share 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. Link to comment Share on other sites More sharing options...
Valik Posted March 11, 2004 Share 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. Link to comment Share on other sites More sharing options...
BlueScreen Posted March 11, 2004 Author Share 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? Link to comment Share on other sites More sharing options...
BlueScreen Posted March 11, 2004 Author Share 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? Link to comment Share on other sites More sharing options...
Administrators Jon Posted March 11, 2004 Administrators Share 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/ Link to comment Share on other sites More sharing options...
BlueScreen Posted March 11, 2004 Author Share Posted March 11, 2004 OK. So I'll overwrite the array with the new params. 10x everybody... Link to comment Share on other sites More sharing options...
Valik Posted March 11, 2004 Share 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now