PerryRaptor Posted February 10, 2007 Share Posted February 10, 2007 Is there a method to break out of a called function early? Link to comment Share on other sites More sharing options...
Valuater Posted February 10, 2007 Share Posted February 10, 2007 I don't think there is a "method", however there are many ways of doing it we would need an example code to help 8) Link to comment Share on other sites More sharing options...
nitekram Posted February 10, 2007 Share Posted February 10, 2007 What about - Return 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
J0ker Posted February 10, 2007 Share Posted February 10, 2007 Code please then we might be able to help you. Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 10, 2007 Author Share Posted February 10, 2007 (edited) This is the function that I need a method to breakout of. Func CountDown() If $array[3] = "" Then Exit(1) $Config = $array[3] $CommunityPatch = IniRead($Config, "COMMUNITY", "Patch", "") $LaunchTimerM = IniRead($Config, "CDTIMER","LaunchTimer", 2) $begin = TimerInit() $LaunchTimer = $launchTimerM * 60000 $LaunchTimer1 = $LaunchTimer /2 $LaunchTimer2 = $LaunchTimer /4 While TimerDiff($begin) <= $LaunchTimer ChatBox("Count Down Timer Started with " & $LaunchTimerM & " minutes... ") Sleep($LaunchTimer1) ChatBox("Count Down Time Remaining is " & $LaunchTimer1 /60000 & " minutes...") Sleep($LaunchTimer2) ChatBox("Count Down Time Remaining is " & $LaunchTimer2 /60000 & " minutes... ") Sleep($LaunchTimer2) ControlClick( $CommunityPatch, "", "EXECUTE") Sleep(700) WEnd EndFunc Edited February 10, 2007 by PerryRaptor Link to comment Share on other sites More sharing options...
/dev/null Posted February 10, 2007 Share Posted February 10, 2007 This is the function that I need a method to breakout of. what's wrong with return statement at the right place? If $condition Then return __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 10, 2007 Author Share Posted February 10, 2007 you mean, inside the While...Wend Loop have a line: If $condition Then return Link to comment Share on other sites More sharing options...
/dev/null Posted February 10, 2007 Share Posted February 10, 2007 you mean, inside the While...Wend Loop have a line:If $condition Then returnyes, $condition is just a place holder. Replace with whatever "test" your wnat! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 10, 2007 Author Share Posted February 10, 2007 May be I'm not thinking through this...If I make $Array[5] Global at the beginning then this should work. The "While TimerDiff($begin) <= $LaunchTimer WEnd" part loops every 700ms looking to see if $array[2] is equal to "%StopTimer". This part of the code will continue to step through line be line until the end...Right? If $array[2] = "%StopTimer" Then Return ChatBox("Count Down Timer Started with " & $LaunchTimerM & " minutes... ") Sleep($LaunchTimer1) ChatBox("Count Down Time Remaining is " & $LaunchTimer1 /60000 & " minutes...") Sleep($LaunchTimer2) ChatBox("Count Down Time Remaining is " & $LaunchTimer2 /60000 & " minutes... ") Sleep($LaunchTimer2) ControlClick( $CommunityPatch, "", "EXECUTE") So if another function elsewhere sets $array[2] = "%StopTimer" then this CountDown function will stop? Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 10, 2007 Author Share Posted February 10, 2007 Pulling hair out...I still cannot break out of the function Link to comment Share on other sites More sharing options...
Valuater Posted February 10, 2007 Share Posted February 10, 2007 (edited) Maybe... Dim $retrun = 0 Func CountDown() If $array[3] = "" Then Exit(1) $Config = $array[3] $CommunityPatch = IniRead($Config, "COMMUNITY", "Patch", "") $LaunchTimerM = IniRead($Config, "CDTIMER","LaunchTimer", 2) $begin = TimerInit() $LaunchTimer = $launchTimerM * 60000 $LaunchTimer1 = $LaunchTimer /2 $LaunchTimer2 = $LaunchTimer /4 While TimerDiff($begin) <= $LaunchTimer ChatBox("Count Down Timer Started with " & $LaunchTimerM & " minutes... ") Cycle($LaunchTimer1) If $retrun = 1 then Return ChatBox("Count Down Time Remaining is " & $LaunchTimer1 /60000 & " minutes...") Cycle($LaunchTimer2) If $retrun = 1 then Return ChatBox("Count Down Time Remaining is " & $LaunchTimer2 /60000 & " minutes... ") Cycle($LaunchTimer2) If $retrun = 1 then Return ControlClick( $CommunityPatch, "", "EXECUTE") Sleep(700) WEnd EndFunc Func Cycle($aTime) $iCycle = TimerInit() While $iCycle < $aTime If $retrun = 1 then Return Sleep(100) WEnd EndFunc EDIT ; $iCycle may need to be "difference" or ??? maybe even better $aTime x 1000 or ??? This overall idea should work... I've used it 8) Edited February 10, 2007 by Valuater Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 11, 2007 Author Share Posted February 11, 2007 I added TimerDiff() to get the function to work properly; however, I still cannot break out of the function. Func Cycle($aTime) $iCycle = TimerInit() While TimerDiff($iCycle) < $aTime If $retrun = 1 then Return Sleep(100) WEnd EndFunc I wonder if a DllCall to a Windows Timer would work. Unfortunately I do not know how to do this. Link to comment Share on other sites More sharing options...
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