laurin1 Posted October 25, 2006 Share Posted October 25, 2006 How do I clear or destroy variables, including arrays? Keith Davis MCSA, ZCE, A+, N+ http://www.laurinkeithdavis.com Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted October 25, 2006 Share Posted October 25, 2006 ummm u dont have to clear them you can just set them to something else and it will overwrite it $variable = 5 MsgBox(0,"variable",$variable) $variable = 130 MsgBox(0,"variable",$variable) Link to comment Share on other sites More sharing options...
laurin1 Posted October 25, 2006 Author Share Posted October 25, 2006 ummm u dont have to clear them you can just set them to something else and it will overwrite it $variable = 5 MsgBox(0,"variable",$variable) $variable = 130 MsgBox(0,"variable",$variable) I understand that. However, there are times when I want to make sure the variable is cleared, especially with arrays. From my tests, it appears even arrays can be cleared by setting them $array = ''; but I want to make sure. Keith Davis MCSA, ZCE, A+, N+ http://www.laurinkeithdavis.com Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted October 25, 2006 Share Posted October 25, 2006 yes setting it to blank would clear them but it would be a waste of your time Link to comment Share on other sites More sharing options...
laurin1 Posted October 25, 2006 Author Share Posted October 25, 2006 yes setting it to blank would clear them but it would be a waste of your timeNo, it wouldn't be as waste of my time. I've got an array that is used with a hashing function which is reused, but needs to be cleared before it is reused. Keith Davis MCSA, ZCE, A+, N+ http://www.laurinkeithdavis.com Link to comment Share on other sites More sharing options...
zalomalo Posted February 7, 2015 Share 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) Edited February 7, 2015 by zalomalo My english shucks, i know it. Link to comment Share on other sites More sharing options...
jguinch Posted February 7, 2015 Share Posted February 7, 2015 (edited) If you want to destroy you array, just set you array variable to 0 : $aArray = 0 Edit : Also, you can read the Keyword Dim / Global / Local / Const page in the helpfile : 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: $aArray = 0 This will free the array and convert it back to the single value of 0 Edited February 7, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
BrewManNH Posted February 7, 2015 Share Posted February 7, 2015 Necroing an 8 1/2 year old thread isn't a record, but it's close. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jguinch Posted February 7, 2015 Share Posted February 7, 2015 Ooops... I didn't look at the OP date... Sorry Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
zalomalo Posted February 9, 2015 Share Posted February 9, 2015 (edited) Sorry a lot, i didnt realise was so old post. Sorry. But, jguinch is wrong. Is not enough, i have read the documentation and done 1000 test. Tell me if you are interested in discuss this issue. Cheers. Edited February 9, 2015 by zalomalo My english shucks, i know it. 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