Jump to content
Sign in to follow this  
meowbits

While loop, how to increase every run 1++

Recommended Posts

meowbits

If ($CmdLine[0] = 1) Then 
; Open url to play FarmTown
    _IECreate ("http://apps.facebook.com/farmtown/play/", 1, 1, 1, 1)
    $ON = True
; main loop
    While 1=1
    Sleep(500)
        if $ON = True Then
            
        ; start pixel search for store icon
            $coord1 = PixelSearch(0,0,770,525, $storeIconColor,0)
            If IsArray($coord1) = 1 Then
            ; save coords as 'storeCoords'
                $storeCoords[0] = $coord1[0] 
                $storeCoords[1] = $coord1[1]
                MouseClick("left", $storeCoords[0], $storeCoords[1])
        ; Error msg
            Else
                MsgBox(0,"ERROR","Unable to find Store icon edit your '$storeIconColor'")
            EndIf
            Sleep(300)
        ; start somesort of search to find the 'other' tab - NEED HELP
            $coord2 = 
            
            If IsArray($coord2) = 1 Then
            ; save coords as 'otherCoords'
                $otherCoords[0] = $coord2[0]
                $otherCoords[1] = $coord2[1]
                MouseClick("left", $otherCoords[0], $otherCoords[1])
        ; Error msg
            Else
                MsgBox(0,"ERROR","Unable to find '$otherCoords'")
            EndIf
            Sleep(300)
        ; start pixel search for haybail icon
            $coord3 = PixelSearch(0,0,770,525, $hayBailColor,0)
            If IsArray($coord3) = 1 Then
            ; save coords as 'buyHayBailCoords'
                $buyHayBailCoords[0] = $coord3[0]
                $buyHayBailCoords[1] = $coord3[1]
                MouseClick("left", $buyHayBailCoords[0], $buyHayBailCoords[1])
        ; Error msg
            Else
                MsgBox(0,"ERROR","Unable to find HayBail edit your '$haybailColor'")
            EndIf
            Sleep(300)
        ; start pixel search for grass color
            $coord4 = PixelSearch(0,0,770,525, $grassColor,0)
            If IsArray($coord4) = 1 Then
            ; save coords as 'placeHayBailCoords'
                $placeHayBailCoords[0] = $coord4[0]
                $placeHayBailCoords[1] = $coord4[1]
                
            ; click grass - NEED HELP
            ; need to click in the same spot 
            ; slightly after first click (2x total)
                MouseClick("left", $placeHayBailCoords[0], $placeHayBailCoords[1])
                Sleep(300)
                MouseClick("left", $sellHayBailCoords[0], $sellHayBailCoords[1])
        ; Error msg
            Else
                MsgBox(0,"ERROR","Unable to find Grass edit your '$grassColor'")
            EndIf
            Sleep(300)
        ; start somesort of search to find the 'sell' tab - NEED HELP
            $coord5 = 
            If IsArray($coord5) = 1 Then
            ; save coords as 'confirmSellCoords'
                $confirmSellCoords[0] = $coord5[0]
                $confirmSellCoords[1] = $coord5[1]
                MouseClick("left", $confirmSellCoords[0], $storeCoords[1])
            ; Error msg
            Else
                MsgBox(0,"ERROR","Unable to find 'confirmSellCoords'")
            EndIf
        EndIf
        1++
    WEnd

Getting errors when I do the 1++

But I need it to add one every time.

Help is appreciated =-)

Share this post


Link to post
Share on other sites
Authenticity

Haha, ;] Nope, it's not a valid instruction or statement in any language I know. I don't see why would you need to increase it inside an infinite loop and why it's matter to use While 1=1 instead of anything that can also evaluated to true, say, While 1 or While True...

Anyway, if you're insisting to increase a counter you can do something like:

Dim $iCounter = 1

While $iCounter
   ; ...
   $iCounter +=1
WEnd

Share this post


Link to post
Share on other sites
meowbits

Haha, ;] Nope, it's not a valid instruction or statement in any language I know. I don't see why would you need to increase it inside an infinite loop and why it's matter to use While 1=1 instead of anything that can also evaluated to true, say, While 1 or While True...

Anyway, if you're insisting to increase a counter you can do something like:

Dim $iCounter = 1

While $iCounter
   ; ...
   $iCounter +=1
WEnd
Thanks!!

I need it to count the total number of runs to do, which is a variable that the user gets prompted to enter.

Share this post


Link to post
Share on other sites
foster74

This should give you an idea of a simple way of doing this.

$InputAnswer = InputBox("InputBox", "How many times would you like this script to loop?" , "1")
For $i = 1 to $InputAnswer
    Msgbox(0, "Loop", "Looped " & $i & " times")
Next
    Msgbox(0, "Loop", "Finished!")

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.