AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variable going blank or disappearing.

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Sukarn



Joined: 16 Jun 2007
Posts: 35

PostPosted: Sun Jul 01, 2007 5:31 pm    Post subject: Variable going blank or disappearing. Reply with quote

This is a subroutine in a script I wrote for automating some stuff. The original script is supposed to check a webpage to see how many times its supposed to do a job, then start doing it. In case something interrupts it and after 60 tries its not able to do the job then it should exit the subroutine and return to the routine that called it. The routine then restarts the script with checking how many times the job has to be done again (the website is scanned again). All that is working fine, except its not able to find out the number of times the subroutine has run, hence its not able to exit the subroutine after 60 tries if the word "Click" is not found.

I placed a message box here to check whether the value of i was incrementing correctly and found out that the variable just goes blank after the loop is completed once.
Is this just bad scripting on my part, something I scripted wrong? I've been trying to figure out whats going wrong for two days now.

Code:
Check:
{
   i := 0
   Loop
   {
      i := %i% + 1
      CK = 0
      Clipboard = 0
      Click 1269,177
      Sleep 500
      Click 1269,177
      Sleep 500
      Send ^a^c
      clipboard = %clipboard%
      Loop, parse, Clipboard, `n, `r
      {
         If InStr(A_LoopField, "Click")
         {
            number = %A_LoopField%
            CK = 1
         }
      }
      Click 1269,177
      If CK
      {
         ImageSearch, X, Y, 7, 165, 1277, 232, %ImageFile%
         Click %X%,%Y%
         Err = 0
         Break
      }
      Else If i > 60
      {
         Err = 1
         Break
      }
      MsgBox, %i%
   }
}
Return


Last edited by Sukarn on Sun Jul 01, 2007 5:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
daonlyfreez



Joined: 16 Mar 2005
Posts: 949
Location: Berlin

PostPosted: Sun Jul 01, 2007 5:36 pm    Post subject: Reply with quote

This is wrong:

Code:
i := %i% + 1


use

Code:
i := i + 1


or

Code:
i++

_________________
mirror 1mirror 2mirror 3ahk4.me • PM or
Back to top
View user's profile Send private message
Sukarn



Joined: 16 Jun 2007
Posts: 35

PostPosted: Sun Jul 01, 2007 5:42 pm    Post subject: Reply with quote

daonlyfreez wrote:
This is wrong:

Code:
i := %i% + 1


use

Code:
i := i + 1


or

Code:
i++


Thanks, though now I feel stupid.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group