Sign in to follow this  
Followers 0

Help with exiting a function

6 posts in this topic

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.

Share this post

Link to post
Share on other sites


See "return" in doc...

can be result of an if..then sequence


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

Share this post

Link to post
Share on other sites

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
MsgBox(0,"The sum was", $sum)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post

Link to post
Share on other sites

Thanks for the help. I will try this as soon as I get a chance to open it up again. :x

Share this post

Link to post
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
Sign in to follow this  
Followers 0