 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Delusion
Joined: 16 Jul 2008 Posts: 45
|
Posted: Mon Oct 06, 2008 3:06 pm Post subject: launching subroutine in a function problem |
|
|
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 |
|
 |
Dra_Gon
Joined: 25 May 2007 Posts: 314
|
Posted: Mon Oct 06, 2008 3:56 pm Post subject: |
|
|
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 }.
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 |
|
 |
Delusion
Joined: 16 Jul 2008 Posts: 45
|
Posted: Mon Oct 06, 2008 6:24 pm Post subject: |
|
|
seems like quotes "" did it...works perfect now i added them.dont even know why i didnt try this
thanks anyway |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|