Vitaliy4us Posted June 1, 2017 Posted June 1, 2017 (edited) I have a parent script which includes some other scripts. They are executed one by one. If a problem occures in one of them the script should be scipped and the next one should start. How I can do this. Exit stops the parent scripts, goto is missing. Should I use loop? But it looks not good enough. Is there any other way? Edited June 1, 2017 by Vitaliy4us
water Posted June 1, 2017 Posted June 1, 2017 Hard to tell without having seen your code. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Moderators JLogan3o13 Posted June 1, 2017 Moderators Posted June 1, 2017 @Vitaliy4us it is extremely difficult to give you suggestions with no code to go on. Typically, you would put your code into functions in a single script, or if it is repeatable code you could create a UDF and call it from your main script. How you exit the function, whether in the main script or a UDF, will determine what happens with the rest of the script. Again, tho, it's difficult to drill down to specifics without seeing how your code is laid out. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Vitaliy4us Posted June 1, 2017 Author Posted June 1, 2017 This is the code: ;Test suit #1 #include "commonConstantsAndFunctions.au3" Local $log = "testsuit1.log" FileWrite($log, "Test suit number 1" & @CRLF & @CRLF) #include "test1_1.au3" MsgBox(0, "Test suit 1", "Test 1_1 finished", 2) #include "test1_2.au3" MsgBox(0, "Test suit 1", "Test 1_2 finished", 2) #include "test1_3.au3" MsgBox(0, "Test suit 1", "Test 1_3 finished", 2) #include "test1_4.au3" MsgBox(0, "Test suit 1", "Test 1_4 finished", 2) MsgBox(0, "Test results", "Test suit 1 is finished", 10)
water Posted June 1, 2017 Posted June 1, 2017 Can you please post one of the test1_*.au3 includes so we can see how you call the code in there? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Vitaliy4us Posted June 1, 2017 Author Posted June 1, 2017 (edited) 9 minutes ago, water said: Can you please post one of the test1_*.au3 includes so we can see how you call the code in there? ;Test 1_1. Send fax without attachments. #include "commonConstantsAndFunctions.au3" #include "SysTrayUDF.au3" #include <Date.au3> Local $testName = "Test 1_1. Send fax without attachments." Local $subj = $testName & " " & _now() Local $body = "This is an automation fax for testing fax sending without attachments" If ProcessExists($ClientProcessName) == 0 Then ReloadClient($clientAccounLoginGW, $clientAccounPasswordGW) ;For example if a problem occures here, the script should stop ;and the next one (test1_2.au3) should to continue EndIf OpenFromTray("New fax") Local $ParameterExpectedValue = True Local $ParameterValue = SendFax(1000,$subj, $body, "") WriteToLog($ParameterValue, $ParameterExpectedValue, $testName & " is OK", $testName & " FAILED", False) Edited June 1, 2017 by Vitaliy4us
water Posted June 1, 2017 Posted June 1, 2017 As suggested " put your code into functions". ; Test suit #1 #include "commonConstantsAndFunctions.au3" #include "test1_1.au3" #include "test1_2.au3" #include "test1_3.au3" #include "test1_4.au3" Local $log = "testsuit1.log" FileWrite($log, "Test suit number 1" & @CRLF & @CRLF) test1_1() MsgBox(0, "Test suit 1", "Test 1_1 finished", 2) test1_2() MsgBox(0, "Test suit 1", "Test 1_2 finished", 2) test1_3() MsgBox(0, "Test suit 1", "Test 1_3 finished", 2) test1_4() MsgBox(0, "Test suit 1", "Test 1_4 finished", 2) MsgBox(0, "Test results", "Test suit 1 is finished", 10) test1_1.au3: ;Test 1_1. Send fax without attachments. #include "commonConstantsAndFunctions.au3" #include "SysTrayUDF.au3" #include <Date.au3> Func Test_1_1() Local $testName = "Test 1_1. Send fax without attachments." Local $subj = $testName & " " & _now() Local $body = "This is an automation fax for testing fax sending without attachments" If ProcessExists($ClientProcessName) == 0 Then ReloadClient($clientAccounLoginGW, $clientAccounPasswordGW) EndIf ; If error occurs then end this test and return to the main script If @error = 1 Then Return OpenFromTray("New fax") Local $ParameterExpectedValue = True Local $ParameterValue = SendFax(1000,$subj, $body, "") WriteToLog($ParameterValue, $ParameterExpectedValue, $testName & " is OK", $testName & " FAILED", False) EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Vitaliy4us Posted June 1, 2017 Author Posted June 1, 2017 7 minutes ago, water said: As suggested " put your code into functions". Thank you, it looks much better then using loop/ExitLoop. The only problem is to refurbish 2 hundreds scripts...
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