aiter

Clearing array and keeping dimensions

5 posts in this topic

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

 

Share this post


Link to post
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.

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

I see thanks.

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

eg global $aArr[10][10] = '1' ; assign 1 to every cell

Share this post


Link to post
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...


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

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)

 


√-1 2^3 ∑ π, and it was delicious!

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