danny0 Posted January 3, 2009 Posted January 3, 2009 I'm new to autoit. I know this is an easy question, but how do you delete an array and its values so it can be declared again with new values?
FireFox Posted January 3, 2009 Posted January 3, 2009 (edited) @danny0 Welcome to autoit forum Example : ;Double array Local $array[10][10] $array[5][5] = "something" MsgBox(64, "array", $array[5][5]) $array[5][5] = "" ;delete something to nothing MsgBox(64, "array", $array[5][5]) ;simple array Local $array[10] $array[5] = "something" MsgBox(64, "array", $array[5]) $array[5] = "" ;delete something to nothing MsgBox(64, "array", $array[5]) Cheers, FireFox. Edited January 3, 2009 by FireFox
BugFix Posted January 3, 2009 Posted January 3, 2009 (edited) Hi and Welcome! There are 2 ways. - You declare an empty array and copy it to the one, you want to "delete". Or you can use ReDim. Global $aEmpty[1] Global $array[200] ; or size u want ;... ;... $array = $aEmpty ; now is UBound($array) = 1 ==> an empty element ;============================================= ; with ReDim ReDim $array[1] $array[0] = '' Edited January 3, 2009 by BugFix Best Regards BugFix
danny0 Posted January 3, 2009 Author Posted January 3, 2009 @danny0 Welcome to autoit forum Example : Local $array[10][10] $array[5][5] = "something" MsgBox(64, "array", $array[5][5]) $array[5][5] = "" ;delete something to nothing MsgBox(64, "array", $array[5][5]) Cheers, FireFox.Thanks! That worked great.
SamGleske Posted April 6, 2010 Posted April 6, 2010 To erase an array (maybe because it is a large global array and you want to free the memory), simply assign a single value to it:$array = 0That was quoted from the documentation.http://www.autoitscript.com/autoit3/docs/keywords/Dim.htmSAM
PsaltyDS Posted April 7, 2010 Posted April 7, 2010 (edited) ReDim is not the answer. That changes the number of elements in the array, and only loses the existing data if you change the number of dimensions. Setting the array variable to a non-array value, like $aArray = 0, will do it just fine. But if you want the array to still exist, with the elements empty, then simply re-declare the array: Global $aArray[10][10] ; original array ; Lots of stuff happens, lots of old data in array Global $aArray[10][10] ; re-declare to empty (elements are all still there, but empty now) ; Continue to use freshly emptied array... Edited April 7, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
zalomalo Posted February 7, 2015 Posted February 7, 2015 (edited) This is not enought. If you have custom functions with local arrays you dare to get trash from it. This is the case in the usefull Call() calls, with a array as argument and 'CallArgArray' in array[0]. You will get all wrong. Is needed wipe manually, example: Func __CustomCall($sCadenaLlamada) ;[....] Local $aArgvs=StringSplit($sArgvs,',',1) Local $coder=$aArgvs[0] $aArgvs[0]='CallArgArray' $CallReturn=Call($sFuncName,$aArgvs) For $i=0 To $coder ; Wipe Array $aArgvs[$i]=Null Next If @error=0xDEAD Or @extended=0xBEEF Then $coder=0 Else $coder=$CallReturn EndIf ;[....] Return($coder) Cheers. Edited February 7, 2015 by zalomalo My english shucks, i know it.
zalomalo Posted February 9, 2015 Posted February 9, 2015 (edited) ReDim is not the answer. Indeed, is Not enough. Redeclare, neither. Wipe it every component inside is the only way to not get unvalid old data if you dont know if $Array[0] is real and care of it. Edited February 9, 2015 by zalomalo My english shucks, i know it.
Moderators JLogan3o13 Posted February 9, 2015 Moderators Posted February 9, 2015 zalomalo, did you not noticed that this thread is over 4 years old, and the OP hasn't been active in 5? Please don't resurrect old threads needlessly. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
zalomalo Posted February 9, 2015 Posted February 9, 2015 Sorry, my fault. Im silly. My english shucks, i know it.
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