Jump to content

How to exit from script but not from the program?


Recommended Posts

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 by Vitaliy4us
Link to comment
Share on other sites

Hard to tell without having seen your code.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

  • Moderators

@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!

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 by Vitaliy4us
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...