GoogleDude Posted December 25, 2007 Posted December 25, 2007 Kinda like below! Call("MainFunction") Func MainFunction() Call("SubFunction") Func SubFunction() MsgBox(1024,"Test","This is a test!") Exit EndFunc EndFunc Thanks, GoogleDude
The Ape Posted December 25, 2007 Posted December 25, 2007 No... but you can call other functions from within a function. FixJaw.comTriad-Art.com
erezlevi Posted December 25, 2007 Posted December 25, 2007 yes, but you should write it like this: and you can also return parameters if you define them. and don't put Exit anywhere except the mainfunction or in a IF statement or check. Call("MainFunction") Func MainFunction() Call("SubFunction") MsgBox (0,"end:","") EndFunc Func SubFunction() MsgBox(1024,"Test","This is a test!") EndFunc
Developers Jos Posted December 25, 2007 Developers Posted December 25, 2007 Only shouldn't be using the Call() statement in these cases MainFunction() ; Func MainFunction() SubFunction() MsgBox(0, "end:", "") EndFunc ;==>MainFunction ; Func SubFunction() MsgBox(1024, "Test", "This is a test!") EndFunc ;==>SubFunction SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
The Ape Posted December 25, 2007 Posted December 25, 2007 yes, but you should write it like this: and you can also return parameters if you define them. and don't put Exit anywhere except the mainfunction or in a IF statement or check.Call("MainFunction")Func MainFunction() Call("SubFunction") MsgBox (0,"end:","") EndFuncFunc SubFunction() MsgBox(1024,"Test","This is a test!") EndFuncNo. Your example doesn't show a nested function. It does prove what I stated. And, of course, Jos is correct (call is not necessary). Also, I think it's good practice to "run" another function conditionally from within a function (unless it's for organization purposes) but try not to run a function, which runs another function... which runs another function. FixJaw.comTriad-Art.com
Marshin Posted July 4, 2008 Posted July 4, 2008 is there any way to have the script return to the first function where it left off after running the second function? muttley At last, after two thousand years of research, the illudium Q-36 explosive space modulator.Well, back to the old drawing board.
martin Posted July 4, 2008 Posted July 4, 2008 is there any way to have the script return to the first function where it left off after running the second function? muttleyHave you found a way to stop it doing that then? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Moderators SmOke_N Posted July 4, 2008 Moderators Posted July 4, 2008 Have you found a way to stop it doing that then?No kidding, I had to read that 3 or 4 times lol. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Marshin Posted July 5, 2008 Posted July 5, 2008 I am not looking to simply go back to the top of the first function, I am looking to basically do a GoSub comand but there is not GoSub comand in version 3. muttley At last, after two thousand years of research, the illudium Q-36 explosive space modulator.Well, back to the old drawing board.
Moderators SmOke_N Posted July 6, 2008 Moderators Posted July 6, 2008 I am not looking to simply go back to the top of the first function, I am looking to basically do a GoSub comand but there is not GoSub comand in version 3. muttleySeems the consensus on the net is that no language (worth it's salt) is using GoSub/GoTo anymore "on purpose".For your "GoSub/GoTo" call, it's better to create independent functions and call them as needed.Proper code structuring makes for less errors and better readability for even the coder themselves.http://www.autoitscript.com/forum/index.ph...st&p=505435http://www.autoitscript.com/forum/index.php?showtopic=72973 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Malkey Posted July 6, 2008 Posted July 6, 2008 (edited) I am not looking to simply go back to the top of the first function, I am looking to basically do a GoSub comand but there is not GoSub comand in version 3. muttleyFrom your last post, it appears your still have not got it. Experiment, it's a great teacher. Jos's example with more MsgBox()'s (Message Boxes). MainFunction() MsgBox(0, "", "Just after where MainFunction() was called at the start") Func MainFunction() MsgBox(0, "", "Top of Main Function") SubFunction() MsgBox(0, "", "This is in Main Function() just after the SubFunction() statement") EndFunc ;==>MainFunction Func SubFunction() MsgBox(1024, "", "This is from/inside the SubFunction()") Return EndFunc ;==>SubFunction As you should be able to see is the function that is called from inside the main function does not go back to the top of the first function which it appears you think it does. It doesn't. It acts more like a GoSub command, which you want. The commands in a GoSub block make up the function. And this function (GoSub block) is stored outside of any other functions. It takes it place separately among the other functions you create. If the SubFunction() command returned to the top of the MainFunction() from where it was called, then the MsgBox(0, "", "Top of Main Function") command would appear a second time after the "This is from/inside the SubFunction()" message. I hope this clarifies what's happening. Edit: Added Another MsgBox() now @ 2nd line Edited July 6, 2008 by Malkey
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now