Jump to content
Sign in to follow this  
thepip3r

Efficient function/way to delete an entire array?

Recommended Posts

thepip3r

Right now, I'm just looping through the elements and using _ArrayDelete but is there just a function I can pass an array to make all of it's contents gone? i.e. _ArrayEmpty($arr)??


My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites
-Ultima-

AutoIt makes it easy. Simply reassigning a value to the array, or allowing it to go out of scope is enough to destroy the array. (Yes, nested arrays would be properly destroyed as well)

So basically, if you have

Global $avArray[100000]

and assign values to it, doing something like

$avArray = 0

is enough to delete the entire array.

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Share this post


Link to post
Share on other sites
smashly

To empty an array you can use Dim. eg; Dim $Arr[100]

#include <Array.au3>

Dim $Arr[101]; To create an array

; fill an array with data
For $i = 0 To UBound($Arr) -1
    $Arr[$i] = $i
Next    

_ArrayDisplay($Arr, "Contents of $Arr array")

Dim $Arr[101]; To create an array

_ArrayDisplay($Arr, "Dim $Arr[101]")

$Arr = 0 ; To destroy array

MsgBox(0, "IsArray($Arr)", IsArray($Arr) <> 0)

Cheers

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.