mattw112 Posted June 18, 2010 Posted June 18, 2010 Is there a 'function exit' command in Autoit? I only see "Exit" and "Exitloop" no exit function or exit sub type command. Terry
SleepyXtreme Posted June 18, 2010 Posted June 18, 2010 I think you use return to get out of a function
GEOSoft Posted June 18, 2010 Posted June 18, 2010 (edited) The default action for a Function is to return to the point from which it was called. However you can use an actual Return statement to return a given value to where it was called from. For $i = 1 To 11 MsgBox(0, "Return", $i & " is even number:" & " " & _ChkMod($i)) _ChkMod_3($i)) MsgBox(0, "Return", $i & " is even number:" & " " & _ChkMod_2($i)) Next Func _ChkMod($iNum) If Mod($iNum, 2) = 0 Then Return True Return False EndFunc Func _ChkMod_2($iNum) Local $bMod = False If Mod($iNum, 2) = 0 Then $bMod = True Return $bMod EndFunc Func _ChkMod_3($iNum) If $iNum <= 10 Then Return MsgBox(0, "", "Goodbye") Exit EndFunc Edit: Added more functions to show different methods for exiting functions. In this case, when it gets to 11 only the first Value will be displayed Edited June 18, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
bo8ster Posted June 18, 2010 Posted June 18, 2010 (edited) Is there a 'function exit' command in Autoit?I only see "Exit" and "Exitloop"no exit function or exit sub type command.TerryAutoIT conforms to most other languages (c/java) in this area with the exception of break. There is never a need for a exit function command, you either return a value (which ends the function) or it ends normal when EndFunc is reached.Edit: just saw George's post. He provides a good example Edited June 18, 2010 by bo8ster Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
GEOSoft Posted June 18, 2010 Posted June 18, 2010 I should have added this one too that shows a function working with no explicit return, which is not required because we are operating on a global variable. It should run for ~30 seconds and then exit. Global $iVal = 0 While 1 If Mod(@SEC, 5) = 0 Then _SetVal() MsgBox(0, "Result", $iVal, 3) If $iVal >= 6 Then ExitLoop WEnd Func _SetVal() $iVal += 1 EndFunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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