MakinBaconNeked Posted December 29, 2010 Share Posted December 29, 2010 Hello -I am having troubles figuring out how to exit a function when a certain condition occurs without ending the script. We have a main function that will go check several elements on a single screen. For each element it will do the following:Check that the element exists and is enabled (or disabled depending on the requirement)Check the current value (when the element is a textfield or textarea)Check the activation status (when the element is a checkbox or radio button)Interact with the element or not (depending on the requirement)This main function will perform these steps for 2 buttons, 6 textfields, 1 set of three radio buttons, 4 checkboxes and 3 textareas. (In that order)Unfortunately, I have to have all the actions done in that single main function (we are using a proprietary program that will generate this code for us)The issue is that if, for example, the first textfield that the script handles exists but the current value is incorrect then I need to set a status flag to Fail and exit the main function. The entire script cannot be exited because there will be additional code that needs to occur regardless of that main function passing or failing. Currently, when this situation occurs, the script correctly sets the status flag but continues on to the subsequent elements in the function. I hope this is enough information for you all to provide some suggestions. If you need to see the code it will be several hours before I can generate a script and share it with you. Thanks in advance for all the help. Link to comment Share on other sites More sharing options...
JohnOne Posted December 29, 2010 Share Posted December 29, 2010 Return ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kylomas Posted December 29, 2010 Share Posted December 29, 2010 MBN, See "return" in doc... can be result of an if..then sequence kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
saywell Posted December 29, 2010 Share Posted December 29, 2010 If $Status = "Fail" Then Return William Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 29, 2010 Share Posted December 29, 2010 Maybe ExitLoop? Here's an example quoted from the Help file.$sum = 0 While 1 ;use infinite loop since ExitLoop will get called $ans = InputBox("Running total=" & $sum, _ " Enter a positive number. (A negative number exits)") If $ans < 0 Then ExitLoop $sum = $sum + $ans WEnd MsgBox(0,"The sum was", $sum) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
MakinBaconNeked Posted December 29, 2010 Author Share Posted December 29, 2010 Thanks for the help. I will try this as soon as I get a chance to open it up again. 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