Jump to content

array and for....next loop


ratacat
 Share

Recommended Posts

here is my code...I wanted it to print out ALL the numbers I have assigned in the variable using those two nested for....next loops. I know you could do it very easily with four separate for next loops....but I wanted to try this way. It isn't working, any and all suggestions or lectures welcome.

Dim $select[4]
Dim $spades[4]
Dim $clubs[4]
Dim $dimes[4]
Dim $hearts[4]

;------------------------A3---K2---Q1---J0--------------------------------------
$select[3] = "spades"
$select[2] = "clubs"
$select[1] = "dimes"
$select[0] = "hearts"

$spades[3] = 10888956
$spades[2] = 4194559
$spades[1] = 8404992
$spades[0] = 16744576

$clubs[3] = 16512
$clubs[2] = 33023
$clubs[1] = 16448
$clubs[0] = 8421440

$dimes[3] = 8388736
$dimes[2] = 128
$dimes[1] = 32896
$dimes[0] = 8421376

$hearts[3] = 8388608
$hearts[2] = 8421504
$hearts[1] = 0
$hearts[0] = 16744512

run("notepad.exe")
WinWaitActive("Untitled - Notepad")

for $c = 0 to 3
    for $i = 0 to 3
        $cato = $select[$c]
        send($cato & [$i] & "{ENTER}")
    next
next
Link to comment
Share on other sites

I tried the following:

...

for $c = 0 to 3
    $cato = $select[$c]
    for $i = 0 to 3
        $expr = $cato & "[" & $i & "]"
        $value = Eval($expr)
        send(String($value) & "{ENTER}")
    next
next

Unfortunately the Eval() doesn't return the correct value for the array entry. Am I doing something wrong or is this a bug (Eval() cannot handle array-variables)?

Edited by HighGuy
Link to comment
Share on other sites

Eval() cannot handle array-variables and it is not a bug.

<{POST_SNAPBACK}>

Thank you for the info. I don't know if this is a missing feature or if it's not possible at all. In both cases it should be listed in the doc.

@xeonz16: your problem might not be solvable :lmao:

Link to comment
Share on other sites

This works for me.

Opt("WinTitleMatchMode", 2)

Dim $select[4]
Dim $spades[4]
Dim $clubs[4]
Dim $dimes[4]
Dim $hearts[4]

;------------------------A3---K2---Q1---J0--------------------------------------

$spades[3] = 10888956
$spades[2] = 4194559
$spades[1] = 8404992
$spades[0] = 16744576

$clubs[3] = 16512
$clubs[2] = 33023
$clubs[1] = 16448
$clubs[0] = 8421440

$dimes[3] = 8388736
$dimes[2] = 128
$dimes[1] = 32896
$dimes[0] = 8421376

$hearts[3] = 8388608
$hearts[2] = 8421504
$hearts[1] = 0
$hearts[0] = 16744512

$select[3] = $spades
$select[2] = $clubs
$select[1] = $dimes
$select[0] = $hearts

run("notepad.exe")

WinWait("Notepad")
WinActivate("Notepad")

Sleep(1000)

for $c = 0 to 3
    $cato = $select[$c]
    for $i = 0 to 3
        send($cato[$i] & "{ENTER}")
    next
next
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...