Jump to content
Sign in to follow this  
reb

2D Array Question

Recommended Posts

reb

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

Share this post


Link to post
Share on other sites
Andreik

Isn't same thing like?

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

When the words fail... music speaks

Share this post


Link to post
Share on other sites
reb

You probably want 0 to 6 in your for next loop.

I'm not using 0 in my script. That's why I started with 1 But you are right it is there to be used.

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites
reb

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

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.