olo Posted June 10, 2013 Share Posted June 10, 2013 Hi Folks, Ive got my script working and all is well, however they only work individually so basically comment out the other functions(run 1 at a time). E.G. When Test_Assert is run @error=1 and then it exitloops. Here I want it to go into the Test_ExceptionWindow() loop and then have that go into the Test_Abnormal() loop. Ive tired continueloop etc but cant seem to get it out. While 1 If Test_Assert() Then If @error = 1 Then ExitLoop Else If @error = 0 then Return 0 EndIf WEnd While 1 If Test_ExceptionWindow() Then If @error = 0 Then ExitLoop EndIf WEnd While 1 If Test_Abnormal() Then If @error = 1 Then ExitLoop Else If @error = 0 then Return 0 EndIf WEnd Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 10, 2013 Share Posted June 10, 2013 Why not all in one loop with one status variable? If $status = 1 Then funcA() If $status = 2 Then funcB() If $status = 3 Then funcC() In the functions you set the status. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 Why not all in one loop with one status variable? If $status = 1 Then funcA() If $status = 2 Then funcB() If $status = 3 Then funcC() In the functions you set the status. I see what you mean. So instead of having return 0 and 1. Have like return 0,1,2,3,4 etc? Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 10, 2013 Share Posted June 10, 2013 My thought was, you ve got a function which should be executed untill somthing happens. If that magic thing happens you set the global status variable to the next level. After the functions has finished your script is back in that loop. Then the status is checked and the next step/function is executed. That is all. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 10, 2013 Share Posted June 10, 2013 Somthing like this #include <Date.au3> Global $status = 0 While 1 Switch $status Case 0 ConsoleWrite('The start : ' & _NowCalc() & @CRLF) $status = 1 Case 1 funcA() Case 2 ConsoleWrite('The END' & @CRLF) Exit (0) EndSwitch Sleep(500) WEnd Func funcA() Do ConsoleWrite(@SEC & @CRLF) Sleep(1000) Until @SEC >= 30 $status = 2 EndFunc ;==>funcA Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 Somthing like this #include <Date.au3> Global $status = 0 While 1 Switch $status Case 0 ConsoleWrite('The start : ' & _NowCalc() & @CRLF) $status = 1 Case 1 funcA() Case 2 ConsoleWrite('The END' & @CRLF) Exit (0) EndSwitch Sleep(500) WEnd Func funcA() Do ConsoleWrite(@SEC & @CRLF) Sleep(1000) Until @SEC >= 30 $status = 2 EndFunc ;==>funcA ok so im just trying to get my head around it. In case 0 when $status=1 does that then go to case 1? Link to comment Share on other sites More sharing options...
FireFox Posted June 10, 2013 Share Posted June 10, 2013 No, if you want to link the Case 0 to the Case 1, you need to add a ContinueCase to the end of the Case 0.The code given by Xenobiologist is an example, are you sure that it fits your needs?Br, FireFox. Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 No, if you want to link the Case 0 to the Case 1, you need to add a ContinueCase to the end of the Case 0. The code given by Xenobiologist is an example, are you sure that it fits your needs? Br, FireFox. Im trying to see if it can. Basically want to run through each function in the script. Even if one function runs correctly and exits(outputs a messagebox or something) I still want the script to continue to run the other two functions. Rather than stop after the first execution of the first function....if that makes sense? Link to comment Share on other sites More sharing options...
FireFox Posted June 10, 2013 Share Posted June 10, 2013 (edited) Then I would say the same as in the reply #2.With an advanced example :Local $iStatus = 0 While 1 If $iStatus = 0 Then _MyFuncA() If @error = 1 Then ExitLoop If @error = 0 Then $iStatus = 1 ;go to next func ElseIf $iStauts = 1 Then _MyFuncB() If @error = 1 Then ExitLoop If @error = 0 Then $iStatus = 2 ;go to next func (not written here) EndIf ;etc WEndEdit: Added indents.Br, FireFox. Edited June 10, 2013 by FireFox Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) The function only prints something useful when @error is = 1 or as defined in my code. So can I do the following below? Or is it really bad coding If @error = 1 Then ExitLoop $iStatus = 2 ;can I do this??? If @error = 0 Then $iStatus = 2 Edited June 10, 2013 by olo Link to comment Share on other sites More sharing options...
FireFox Posted June 10, 2013 Share Posted June 10, 2013 If @error = 1 Then $iStatus = 2 ExitLoop EndIf But I don't understand the purpose of updating the variable because all the script is in the loop, or you have something after which uses this variable ? Br, FireFox. Link to comment Share on other sites More sharing options...
DW1 Posted June 10, 2013 Share Posted June 10, 2013 I'm thinking the OP could be a bit more clear. Are you wanting to continue to the next check regardless if the previous passes or fails? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 I'm thinking the OP could be a bit more clear. Are you wanting to continue to the next check regardless if the previous passes or fails? Yea thats what I wanna do. If it passes or fails doesnt matter....check the next function etc Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 If @error = 1 Then $iStatus = 2 ExitLoop EndIf But I don't understand the purpose of updating the variable because all the script is in the loop, or you have something after which uses this variable ? Br, FireFox. updating $status? I thought updating that and placing it into another function would allow me to use that other function? Or at least thats what I gather from the replies so far. Link to comment Share on other sites More sharing options...
DW1 Posted June 10, 2013 Share Posted June 10, 2013 (edited) Yea thats what I wanna do. If it passes or fails doesnt matter....check the next function etc Anything wrong with keeping it super simple then? If Test_Assert() Then $Test1 = 1 Else $Test1 = 0 EndIf If Test_ExceptionWindow() Then $Test2 = 1 Else $Test2 = 0 EndIf If Test_Abnormal() Then $Test3 = 1 Else $Test3 = 0 EndIf Or if each must be in a loop: While 1 If Test_Assert() Then $Test1 = 1 ExitLoop Else $Test1 = 0 ExitLoop EndIf WEnd While 1 If Test_ExceptionWindow() Then $Test2 = 1 ExitLoop Else $Test2 = 0 ExitLoop EndIf WEnd While 1 If Test_Abnormal() Then $Test3 = 1 ExitLoop Else $Test3 = 0 ExitLoop EndIf WEnd Edited June 10, 2013 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
FireFox Posted June 10, 2013 Share Posted June 10, 2013 updating $status? I thought updating that and placing it into another function would allow me to use that other function? Or at least thats what I gather from the replies so far. Because that's what we understood. Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 10, 2013 Share Posted June 10, 2013 If it doesn't matter what happens inside your functions then you needn't to react on the return value at all. I don't get it $count = 1 While 1 ConsoleWrite('!Run : ' & $count & @CRLF) _a() _b() _c() $count += 1 WEnd Func _a() ConsoleWrite('a' & @CRLF) Sleep(500) EndFunc ;==>_a Func _b() ConsoleWrite('b' & @CRLF) Sleep(500) EndFunc ;==>_b Func _c() ConsoleWrite('c' & @CRLF) Sleep(500) EndFunc ;==>_c Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
olo Posted June 10, 2013 Author Share Posted June 10, 2013 ok thanks guys for the replies. Im gonna go off and try somethings. As there's a problem with my logic somewhere. 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