Jump to content

Clearing array and keeping dimensions


Recommended Posts

I have an array $aArr[50][10]

I have a loop that builds the values within this array

At the beginning of the loop, I want to clear out this array but keep its dimensions

Do I need to loop through all the rows and the columns and assign null to each cell or is there an easier way

global $aArr[50][10]
While flag
  $aArr = ''  ;<---- I think this will clear it, but how do I specify its an array again
  ; code below this will fill $aArr
wend

 

Link to comment
Share on other sites

Redeclare the Array... Something like this:

#include <Array.au3>

Global $aArray[3] = [1, 2, 3] ; Create the array for the first time

_ArrayDisplay($aArray) ; Display the array

Global $aArray[3] ; Redeclare the array

_ArrayDisplay($aArray) ; Display the array again

; P.S Try running this script to see what I mean.

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Just now, aiter said:

Is there way to blanket initialize an array to a value?

Not that I know of, You need to a custom code a loop for that...

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • Moderators

Something like this to fill it?

#include <Array.au3>

Local $aArray[10][10]

    _ArrayDisplay($aArray)

    For $a = 0 To 9
        For $b = 0 To 9
            $aArray[$a][$b] = 1
        Next
    Next

    _ArrayDisplay($aArray)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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