Sign in to follow this  
Followers 0
1224

2d array looping

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.  

Share this post


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

Share this post


Link to post
Share on other sites

Thanks for quick reply

My Pleasure, I had the time :graduated:

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.  

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  
Followers 0