Jump to content

2d array looping


1224
 Share

Recommended Posts

A script like this

For $i = 0 To 4 Step +1
    $a[$i][0] = 47
    $a[$i][1] = 3
    $a[$i][2] = 99
Next

I want to do something like below:

While $a[$loop] has data

MsgBox(0, "", $a[$loop][0] & " - " & $a[$loop][1] & " - " & $a[$loop][2])

$loop += 1

WEnd

i.e.

The looping will be :

MsgBox(0, "", $a[$loop][0] & " - " & $a[0][1] & " - " & $a[0][2])

MsgBox(0, "", $a[$loop][1] & " - " & $a[1][1] & " - " & $a[1][2])

MsgBox(0, "", $a[$loop][2] & " - " & $a[2][1] & " - " & $a[2][2])

MsgBox(0, "", $a[$loop][3] & " - " & $a[3][1] & " - " & $a[3][2])

MsgBox(0, "", $a[$loop][4] & " - " & $a[4][1] & " - " & $a[4][2])

But assume that I don't know the max index of $i

How can I do?

Link to comment
Share on other sites

Hello 1224,

I am not sure I fully understand your question or your dilemma, but taking a guess, you want to find a way to get the maximum index of your array. If that is correct look at the function Ubound().

For $i = 0 To Ubound($a)-1
    $a[$i][0] = 47    
    $a[$i][1] = 3    
    $a[$i][2] = 99 
Next

Realm

Edit: Fixed typos.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Hello 1224,

I am not sure I fully understand your question or your dilemma, but taking a guess, you want to find a way to get the maximum index of your array. If that is correct look at the function Ubound().

For $i = 0 To Ubound($a)-1
    $a[$i][0] = 47    
    $a[$i][1] = 3    
    $a[$i][2] = 99 
Next

Realm

Edit: Fixed typos.

yes

Thanks for quick reply

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