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 

Create my own functions and call them from inside a script.

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



Joined: 02 Sep 2008
Posts: 26

PostPosted: Wed Sep 16, 2009 1:10 pm    Post subject: Create my own functions and call them from inside a script. Reply with quote

Not sure I'm using the correct terminology there but here's what I'd like to do.

I have this script, it works great, but I have this loop in it that I use to pause the script while it's executing.

This is sprinkled all over my script:

Code:
Loop
{
  Sleep, 1000
  If A_Cursor not contains AppStarting,Wait
  break
}


What I tried to do was make it a function (again not sure if that is the correct terminology) and call it with gosub:

Code:
script excuting blah blah blah
gosub, pfp
more script excuting blah blah blah


; FUNCTIONS

PFP: ; Pause For Program
Loop
{
  Sleep, 1000
  If A_Cursor not contains AppStarting,Wait
  break
}


But when I do that I the more script executing stuff doesn't excute.
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Sep 16, 2009 1:17 pm    Post subject: Reply with quote

Code:
script excuting blah blah blah
pfp()
more script excuting blah blah blah

; FUNCTIONS

PFP(){ ; Pause For Program
  Loop
  {
    Sleep, 1000
    If A_Cursor not contains AppStarting,Wait
      return
  }
}

???
Back to top
iguru42



Joined: 02 Sep 2008
Posts: 26

PostPosted: Wed Sep 16, 2009 2:36 pm    Post subject: Reply with quote

That works perfectly, thanks!
Back to top
View user's profile Send private message
gargoyle888



Joined: 10 Jan 2009
Posts: 9

PostPosted: Wed Sep 16, 2009 5:51 pm    Post subject: Reply with quote

Code:
script excuting blah blah blah
gosub, pfp
more script excuting blah blah blah


; FUNCTIONS

PFP: ; Pause For Program
Loop
{
  Sleep, 1000
  If A_Cursor not contains AppStarting,Wait
  break
}
Return
Back to top
View user's profile Send private message
PurloinedHeart



Joined: 04 Apr 2008
Posts: 374
Location: Canada

PostPosted: Wed Sep 16, 2009 11:27 pm    Post subject: Reply with quote

Quote:
Although Gosub is useful for simple, general purpose subroutines, consider using functions for more complex purposes.

http://www.autohotkey.com/docs/Functions.htm
Back to top
View user's profile Send private message
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