Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Function Exit Command?


  • Please log in to reply
4 replies to this topic

#1 mattw112

mattw112

    Prodigy

  • Active Members
  • PipPipPip
  • 182 posts

Posted 18 June 2010 - 05:50 AM

Is there a 'function exit' command in Autoit?
I only see "Exit" and "Exitloop"
no exit function or exit sub type command.

Terry







#2 SleepyXtreme

SleepyXtreme

    Prodigy

  • Active Members
  • PipPipPip
  • 194 posts

Posted 18 June 2010 - 05:53 AM

I think you use return to get out of a function
Programs:AAST (Andrew's Anti Snooping Tool) - Elite protection from prying eyes with tons of functionality_TooBigForForums - Downloads your program and opens it (For when you have exceeded your upload limit but still want to know how many downloads you have).

#3 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 18 June 2010 - 06:18 AM

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.

Plain Text         
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 by GEOSoft, 18 June 2010 - 06:38 AM.

GeorgeQuestion 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!"

#4 bo8ster

bo8ster

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,189 posts

Posted 18 June 2010 - 06:27 AM

Is there a 'function exit' command in Autoit?
I only see "Exit" and "Exitloop"
no exit function or exit sub type command.

Terry

AutoIT 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 by bo8ster, 18 June 2010 - 06:29 AM.

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)Brett F's Learning To Script with AutoIt V3Valuater's AutoIt 1-2-3, Class... is now in SessionContribution: Get SVN Rev Number, Control Handle under mouse, A Presentation using AutoIt, Log ConsoleWrite output in Scite

#5 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 18 June 2010 - 06:56 AM

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

GeorgeQuestion 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!"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users