olo Posted May 1, 2013 Posted May 1, 2013 I am trying to return a value of 1 = pass, 0 = fail. But I dont know if my winexists is the correct function to use? Is there a function that after I run my command and it was successful that I can return 1 or 0. As I think my If statement is wrong #include-once Func RemovePath($RmPath) DirRemove($RmPath, 1) EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #include <..\Library\RemovePath.au3> Func Test_RemovePath() Local $var = EnvGet("HOMEDRIVE") Local $var1 = EnvGet("HOMEPATH") Local $RmPath = $var & "\" & $var1 & "\Desktop\EEX\DDX\" RemovePath($RmPath) If FileExists($RmPath) Then Return 1 Else Return 0 EndIf EndFunc
water Posted May 1, 2013 Posted May 1, 2013 Most of the AutoIt functions return a value and set the macros @error and @extended to 0 if the function ran succesfully. If an error occurred then either thze return value or @error that and which error happened. olo 1 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
olo Posted May 1, 2013 Author Posted May 1, 2013 Most of the AutoIt functions return a value and set the macros @error and @extended to 0 if the function ran succesfully.If an error occurred then either thze return value or @error that and which error happened.Ok thanks man. I shall research into this @error.
water Posted May 1, 2013 Posted May 1, 2013 Make sure to test the return value OR @error. Not all functions set the return value, not all functions set @error to denote an error - it depends on the function. The help file is your friend! 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
olo Posted May 1, 2013 Author Posted May 1, 2013 Make sure to test the return value OR @error. Not all functions set the return value, not all functions set @error to denote an error - it depends on the function.The help file is your friend!I have msgboxes in place. But does SetError(1) set the @error = 1? As there is a SetError(2)? I thought it would be SetError(0) to have @error = 0
water Posted May 1, 2013 Posted May 1, 2013 Accordibng to the help file:The first parameter sets the value of @error, the second of @extended and the third the return value.ExampleFunc Test() Return SetError(7, 12345, "Wrong Result") EndFunc olo 1 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
olo Posted May 1, 2013 Author Posted May 1, 2013 (edited) Accordibng to the help file: The first parameter sets the value of @error, the second of @extended and the third the return value. ExampleFunc Test() Return SetError(7, 12345, "Wrong Result") EndFunc Yea the help file is a bit confusing for this one. So can I say If @error = 0 Then MsgBox(4096, "Success", "Yes") SetError(1) Return 1 Else MsgBox(4096, "Error", "No") Return 0 EndIf Edited May 1, 2013 by olo
water Posted May 1, 2013 Posted May 1, 2013 I wouldn't set @error on success. Use something like this: If @error = 0 Then MsgBox(4096, "Success", "Yes") Return 1 Else MsgBox(4096, "Error", "No") Return 0 EndIf olo 1 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
olo Posted May 1, 2013 Author Posted May 1, 2013 I wouldn't set @error on success. Use something like this: If @error = 0 Then MsgBox(4096, "Success", "Yes") Return 1 Else MsgBox(4096, "Error", "No") Return 0 EndIf Was just about to thank you. Managed to get that one.
water Posted May 1, 2013 Posted May 1, 2013 Glad you got it working olo 1 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
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