Jump to content
Sign in to follow this  

AutoIT ignores my For loop statment? Only runs for loop once!

Recommended Posts


The code:

For $i = 1 To 5 Step 1
        ;first, find a path that matches our filter
        MsgBox(0,"the type of this path", _XMLGetAttrib($zonePath & "/" & $tempPathNameArray[$i], "type"))

        If (_XMLGetAttrib($zonePath & "/" & $tempPathNameArray[$i], "type") == $pathType) Then

            $pathPath = $zonePath & "/" & $tempPathNameArray[$i]
            ;now count how many nodes we have
            $nodeCount = _XMLGetNodeCount($pathPath & "/*")
            For $i = 0 To ($nodeCount - 1) Step 1
                ;for each node, check and compare x and y values
                $temp1DArray[$i] = _XMLGetAttrib($pathPath & "/Node" & $i, "x")
                $temp1DArray2[$i] = _XMLGetAttrib($pathPath & "/Node" & $i, "y")
                $tempDistance = _Distance($playerX, $playerY, $temp1DArray[$i], $temp1DArray2[$i])

                If $tempDistance < $minDist Then
                    $minDist = $tempDistance
                    $minDistx = $temp1DArray[$i]
                    $minDisty = $temp1DArray2[$i]
                    $minpathPath = $pathPath
                    $minnodeNum = $i

            MsgBox(0,"returned a min dist of",$minDist)


This for loop, when run by autoit, only pops up the msgbox "test" "test" a single time.

But that is impossible! Because it is sitting in a for loop that goes to 5 with a step of 1!!

What the heck?!

*EDIT: Sorry i forgot basic array 101, never use the same array variable ($i) inside of a nested for loop.

Oops can i get a delete? ;)(

Edited by mavor

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.