PcExpert Posted February 9, 2009 Share Posted February 9, 2009 Hi all, I was wondering how to delete the contents of an array. Some users may remember my Checkboxes array, thats what this is about. When a user opens the window I get an array with checkboxes, once I close the window I want it to delete all contents of the array (if I dont do that, I get an array error for the amount of subscripts or the range that has been exceeded), I tried it with: _ArrayDelete($CheckBox, "")oÝ÷ Ù©ÝÂ+ajëh×6Guictrlsetdata($Checkbox, "") But I'm still getting the array error. (untill I restart the program ofcourse, but that is out of the question;)) So the question is, how to empty an array completely? Thanks! Link to comment Share on other sites More sharing options...
BrettF Posted February 9, 2009 Share Posted February 9, 2009 Post your code. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Manjish Posted February 9, 2009 Share Posted February 9, 2009 i know this is not the best way to go about it, but still it will do the job: For $i=1 to $array[0] $array[$i]="" Next [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 9, 2009 Moderators Share Posted February 9, 2009 PcExpert,From the Help file (under Dim):If you want to destroy the array: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 = 0. This will free the array and convert it back to the single value of 0.So to completely destroy an array: $vakken_array = 0If you want to keep the array to reuse, but clear the array elements:Declaring the same variable name again will erase all array values and reset the dimensions to the new definition.So to set all elements to 0/NULL: Global $vakken_array[size required]To be complete, using ReDim will change the array size, but retain the existing values in the elements which remain untouched.Hope that is clear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 9, 2009 Moderators Share Posted February 9, 2009 PcExpert,After a quick look (it is 1500 lines after all!), the obvious problem is that you are not resetting $count to zero as you enter the function. So your value of $count is likely to be different to (and probably much larger than) the top index of $vakken_array. That would give you the error you mentioned.Try adding $count = 0 at the beginning of Func group_vakadd().And when will you change those ugly loops? Two of us have offered you a better way to do that bit!M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PcExpert Posted February 9, 2009 Author Share Posted February 9, 2009 (edited) @M23, Thanks for your help. As I said, I was going to implement it in the next version, that version is the next one. I didnt implement it directly, because I first wanted to get rid of the array problems . Edited February 9, 2009 by PcExpert 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