Jump to content
Sign in to follow this  
LizardLord

Is there a way to Delete all data in a single 1D array with a Function, User defined or otherwise?

Recommended Posts

LizardLord

I am working on a small script that will determine changes to a Folder/File in real time and automaticley inform me of this and replace the file with a backup version, everything seems to be going well, althouh I was Wondering is there a way to delete all data in an entire array with a function, or do i have to write it custom.

-Lizard Lord

Share this post


Link to post
Share on other sites
Danny35d

Dim $aNumbers[100]
For $x = 0 to UBound($aNumbers) - 1
    $aNumbers[$x] = $x
Next

MsgBox(0, 'Empty array', '$aNumbers is an array: ' & IsArray($aNumbers))
$aNumbers = ''  ; Delete all data
MsgBox(0, 'Empty array', '$aNumbers is an array: ' & IsArray($aNumbers))


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites
ResNullius

Dim $aNumbers[100]
For $x = 0 to UBound($aNumbers) - 1
    $aNumbers[$x] = $x
Next

MsgBox(0, 'Empty array', '$aNumbers is an array: ' & IsArray($aNumbers))
$aNumbers = ''  ; Delete all data
MsgBox(0, 'Empty array', '$aNumbers is an array: ' & IsArray($aNumbers))
This will empty the array, but it also destroys the array.

So if you want to clear it using this method and then repopulate it, you will have to declare it again afterwards:

$aNumbers = '' ; Delete all data
MsgBox(0, 'Empty array', '$aNumbers is an array: ' & IsArray($aNumbers))
Dim $aNumbers[100]

Share this post


Link to post
Share on other sites
PsaltyDS

I am working on a small script that will determine changes to a Folder/File in real time and automaticley inform me of this and replace the file with a backup version, everything seems to be going well, althouh I was Wondering is there a way to delete all data in an entire array with a function, or do i have to write it custom.

-Lizard Lord

The critical questions are whether you want it to still be an array, and if so with how many elements?

Simply destroy the array - no longer an array type:

$avArray = ""

Destroy all elements - still a minimal array type with only one null element:

Dim $avArray[1]

Null the data in all elements - still an array of the same size:

Dim $avArray[Ubound($avArray)]

:mellow:


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

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.