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 

Problem with blocks {}

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Mauser
Guest





PostPosted: Fri May 16, 2008 9:01 pm    Post subject: Problem with blocks {} Reply with quote

I am very new for AHK and I have problem with {} blocks.

This is code is not compiled:

activate:
cont=0
loop %repeat_number% {
if cont=0 {
mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
cont=1
}
sleep, %ms_between%
}
return

This code is compiled correctly:

activate:
cont=0
loop %repeat_number% {
mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
sleep, %ms_between%
}
return

Could you please tell how to add "if" block in to the loop?
Back to top
TheIrishThug



Joined: 19 Mar 2006
Posts: 370

PostPosted: Fri May 16, 2008 9:21 pm    Post subject: Reply with quote

If you are going to do if statements without parenthesis, which i don't recommend, you can't put the open bracket on the same line.
Code:
;works
if (count = 1) {
  ...
}
;works
if count = 1
{
  ...
}
;DOESN'T WORK
; this would be equivalent to if (count = "1 {")
if count = 1 {
 ...
}
Back to top
View user's profile Send private message Visit poster's website AIM Address
crxvfr



Joined: 10 Mar 2006
Posts: 54

PostPosted: Fri May 16, 2008 9:25 pm    Post subject: Re: Problem with blocks {} Reply with quote

1. Registered users get better answers
2. Use the code tags when posting code. It keeps indents intact.
3. If you aren't already, use indents to keep better track of opening and closing braces
4. See below.

Code:

activate:
cont=0
loop %repeat_number%
   {
   if cont=0
      {
      mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
      cont=1
      }
   sleep, %ms_between%
   }
return

This code is compiled correctly:
Code:

activate:
cont=0
loop %repeat_number%
   {
   mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
   sleep, %ms_between%
   }
return


It may be easier to see whats inside what.
Back to top
View user's profile Send private message
Mauser
Guest





PostPosted: Fri May 16, 2008 9:58 pm    Post subject: Reply with quote

TheIrishThug, crxvfr, got it, thank you
Back to top
Display posts from previous:   
Post new topic   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