Jump to content

Help with exiting a function


Recommended Posts

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

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

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...