Jump to content

2D Array Question


 Share

Recommended Posts

Hi,

I have a 2D Array that I am clearing with a for next loop. I have looked at the arrays in the help file and can't figure a better way of doing it with the available functions. Looked at some (I'm sure not all) array topics on line.

#include <Array.au3>

Global $i, $NameScore[7][2]

$NameScore[1][0] = "1"
$NameScore[2][0] = "2"
$NameScore[3][0] = "3"
$NameScore[4][0] = "4"
$NameScore[5][0] = "5"
$NameScore[6][0] = "6"
$NameScore[1][1] = "1"
$NameScore[2][1] = "2"
$NameScore[3][1] = "3"
$NameScore[4][1] = "4"
$NameScore[5][1] = "5"
$NameScore[6][1] = "6"

_ArrayDisplay($NameScore)
ClearNameScore()
_ArrayDisplay($NameScore)

Func ClearNameScore()
    For $i = 1 To 6
        $NameScore[$i][0] = ""
        $NameScore[$i][1] = ""
    Next
EndFunc   ;==>ClearNameScore

Is this the only way to do this.

Thanks,

REB

MEASURE TWICE - CUT ONCE

Link to comment
Share on other sites

Isn't same thing like?

$NameScore = 0
Dim $NameScore[7][2]

Thank you Andreik

That works. I did not know you could re dimension arrays. It's not a good day if you do not learn something new.

Thanks again

REB

I looked in the help file for dim and found this:

You should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array.

Since I am doing a global I replaced the dim with global and that works too. :)

Edited by reb

MEASURE TWICE - CUT ONCE

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