Sign in to follow this  
Followers 0
IrishPride

Func in a Func

10 posts in this topic

#1 ·  Posted (edited)

Hey again, guys!

I have another question regarding funcs. For my recent project, I was trying to put in function inside of another function, in an attempt to make the second function run after the first one had finished; while both riding the same loop.

Here was my script :

HotKeySet( "{F1}" , "Start" )
HotKeySet( "{F2}" , "Start 2" )


WinActivate( "New Text Document" )

Func Start()
    Send( "1/10" )
    Send( "2/10" )
    Send( "3/10" )
    Send( "4/10" )
    Send( "5/10" )
    Send( "6/10" )
    Send( "7/10" )
    Send( "8/10" )
    Send( "9/10" )
    Send( "10/10" )
    
    
    Func Start 2()
    Send( "11/10 - WINNING!" )
    EndFunc
EndFunc

While 1
Sleep( 250 )
WEnd

Which, obviously doesn't work.. :\ Does anyone know how to finish this script? Thanks in advance

-IrishPride

Edited by IrishPride

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

put a function call at the end of the first function

HotKeySet( "{F1}" , "Start" )
HotKeySet( "{F2}" , "Start 2" )


WinActivate( "New Text Document" )

Func Start()
    Send( "1/10" )
    Send( "2/10" )
    Send( "3/10" )
    Send( "4/10" )
    Send( "5/10" )
    Send( "6/10" )
    Send( "7/10" )
    Send( "8/10" )
    Send( "9/10" )
    Send( "10/10" )
    
    Start 2()
EndFunc

Func Start 2()
    Send( "11/10 - WINNING!" )
EndFunc
Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks! That's exactly what I was looking for. And I appreciate your quick response!

-IrishPride

-----

Edit: Didn't work; tried taking the hotkeys out, and it will now send the first one, but the second still doesnt send.

inActivate( "New Text Document" )
Start()


Func Start()
    
    WinActivate( "New Text Document" )
    Send( "1/10" )
    Send( "2/10" )
    Send( "3/10" )
    Send( "4/10" )
    Send( "5/10" )
    Send( "6/10" )
    Send( "7/10" )
    Send( "8/10" )
    Send( "9/10" )
    Send( "10/10" )
    
    Start Test()
    Sleep ( 1500 )
    EndFunc

Func Test()
    Send( "11/10 - WINNING!" )
    Sleep( 25000 )
EndFunc

What am I doing wrong?

Edited by IrishPride

Share this post


Link to post
Share on other sites

Does that script even run? I'd think that it would crash as soon as it hit the Start Test() line, seeing as there's no command called start. Also, function names can't have spaces in them.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Does that script even run? I'd think that it would crash as soon as it hit the Start Test() line, seeing as there's no command called start. Also, function names can't have spaces in them.

Thats why I broke it down to 'test'. Do you know how to fix it, changing it's name to Test?

Share this post


Link to post
Share on other sites

Get rid of the Start in front of Test() as a beginning.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Just Test(), not Start Test().


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Ah, great. It's workin now. Thanks again guys!

-IrishPride

Share this post


Link to post
Share on other sites

Send( "11/10 - WINNING!" )

I'm sorry but it being Friday and after a long week of work. See this part of the code made me :huh2:;)

Being from L.A. and just thinking about Charlie Sheen and his rants.

Nothing really constructive but good humor for me.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I'm sorry but it being Friday and after a long week of work. See this part of the code made me :huh2:;)

Being from L.A. and just thinking about Charlie Sheen and his rants.

Nothing really constructive but good humor for me.

Thanks, I try :alien:

/thread

Edited by IrishPride

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0