Jump to content
Sign in to follow this  
erezlevi

two dimension array?

Recommended Posts

erezlevi

hi,

why can't I get the second dimension values inside $r?

#include <Array.au3>

Dim $a[10][20] = [[1,2,3,4,5,6,7,8,9,0],[11,12,13,14,15,16,17,18,19,20]]

for $i=1 to 10
    $r=$a[][$i]
    MsgBox (0,"this is $r",$r)
Next

Share this post


Link to post
Share on other sites
martin

hi,

why can't I get the second dimension values inside $r?

#include <Array.au3>

Dim $a[10][20] = [[1,2,3,4,5,6,7,8,9,0],[11,12,13,14,15,16,17,18,19,20]]

for $i=1 to 10
    $r=$a[][$i]
    MsgBox (0,"this is $r",$r)
Next
A nice mess you've got there erezlevi!

You have declared $a to be a 10 x 20 array then given it values that are 2 x 10.

You have no index for the first element for $a inside the for/next loop.

You are going from 1 to 10 but yu need to go from 0 to 9.

Try this

#include <Array.au3>

Dim $a[2][10] = [[1,2,3,4,5,6,7,8,9,0],[11,12,13,14,15,16,17,18,19,20]]
$J= 1
for $i=0 to 9
    $r=$a[$J][$i]
    MsgBox (0,"this is $r",$r)
Next

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Valuater

Dim $a[2][10] = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]

For $i = 0 To 1
    For $ii = 0 To 9
        $r = $a[$i][$ii]
        MsgBox(0, "this is $r", $r, 1)
    Next
Next

....... tooooo slow!!!

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Thatsgreat2345

A nice mess you've got there erezlevi!

You have declared $a to be a 10 x 20 array then given it values that are 2 x 10.

You have no index for the first element for $a inside the for/next loop.

You are going from 1 to 10 but yu need to go from 0 to 9.

Try this

#include <Array.au3>

Dim $a[2][10] = [[1,2,3,4,5,6,7,8,9,0],[11,12,13,14,15,16,17,18,19,20]]
$J= 1
for $i=0 to 9
    $r=$a[$J][$i]
    MsgBox (0,"this is $r",$r)
Next
Lol was $J = 1 really necessary lol?

Share this post


Link to post
Share on other sites
herewasplato

Dim $a[2][20] = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]

For $i = 0 To 9
    $r = $a[0][$i]
    MsgBox(0, "this is $r", $r)
Next

For $i = 0 To 9
    $r = $a[1][$i]
    MsgBox(0, "this is $r", $r)
Next
Val [edit: & others] beat me to it - but here is another way to look at it...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
martin

Lol was $J = 1 really necessary lol?

It's surprising how few things in the world are really necessary. I was just too lazy to do what Valuater and herewasplato did :D .

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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.