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 

launching subroutine in a function problem

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



Joined: 16 Jul 2008
Posts: 45

PostPosted: Mon Oct 06, 2008 3:06 pm    Post subject: launching subroutine in a function problem Reply with quote

i took the mmps button and modified it a bit for a script im making but i want to make a function out of it so that i dont have to write the whole code for every button i make.

this is what i did :

ButVar = the variable of the control to show/hide
SubR = the subroutine to go when the button is pressed

Code:

ButtonEffect( ButVar, SubR) {
  GuiControl Hide, %ButVar%
  Loop {
    MouseDown := GetKeyState("LButton","P")
    If (!MouseDown) {
       Click = 1
       Break
    }
  }
  GuiControl Show, %ButVar%
  IfEqual Click, 1, GoSub, %SubR%
}


it works ok when i put the whole code in.but not as a function.
it always says that there was a problem with launching SubR
what am i doing wrong?
Back to top
View user's profile Send private message
Dra_Gon



Joined: 25 May 2007
Posts: 314

PostPosted: Mon Oct 06, 2008 3:56 pm    Post subject: Reply with quote

Try it like this:
Code:
ButtonEffect(ButVar,SubR) ; Spaces taken out here and open bracket moved to next line.
 {
  GuiControl Hide, %ButVar%
  Loop {
    MouseDown := GetKeyState("LButton","P")
    If (!MouseDown) {
       Click = 1
       Break
    }
  }
  GuiControl Show, %ButVar%
  IfEqual Click, 1, GoSub, %SubR%
}

I don't know the rest of your code so I don't know what else might be going on. I did try on one of my own scripts and was able to gosub an outside sub {also, the changes I made in yours above didn't make any difference, but, personally, I just think it looks better this way Confused }.

Make sure that if you are using actual text to call your function that you put that in quotes:
ButtonEffect(btnGo,"MySub")
btnGo would be a variable and MySub would be the actual name of a sub-routine. Hope this helps!

Ciao,
Dra'Gon
_________________

For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/
Back to top
View user's profile Send private message Send e-mail
Delusion



Joined: 16 Jul 2008
Posts: 45

PostPosted: Mon Oct 06, 2008 6:24 pm    Post subject: Reply with quote

seems like quotes "" did it...works perfect now i added them.dont even know why i didnt try this
thanks anyway
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