Jump to content

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


Recommended Posts

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

Link to comment
Share on other sites

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

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]
Link to comment
Share on other sites

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
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...