Jump to content

Delete array contents


 Share

Recommended Posts

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

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

  • Moderators

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 = 0

If 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@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 by PcExpert
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...