Okay, I think I got it figured out. Not totally fixed, but closer to understanding what is happening. I had to insert a lot of WriteLn commands to trace the programming steps.
I modified my code to the second format that Ray provided making each test its own ELSE section. But, even when a test failed, it still ran code at the bottom of the tests that I did not want running.
One of the things that happens in SubRoutine is to increment vFailed. It aborts the process after three failures.
So, I changed the SubRoutine to a Function, FuncFailed as Int with the same input variables, and returned vFailed as a value.
Function FuncFailed(Color as String,vErrorCode as String) as Int
Function steps in these lines ....
........
........
Return vFailed
End Function
I declared the variable vFailed at the top of the code. It is already declared and initialized to 0 in the Global Code section where its value is updated in the FuncFailed.
Then I changed the lines calling the subroutine to a function call:
var vFailed as Int
.....
.....
.....
vErrorCode="Some text values"
vFailed=FuncFailed(Color,vErrorCode).
And finally at the end of the testing ELSE loops, I inserted the following line:
}
}
}
If vFailed = 0 Then {
The rest of the code goes in here between the braces....
..........
..........
}
That forced the flow after the tests to skip the rest of the code. Looks good so far....
Now the big surprise... When a test failed, the flow went to the end as programmed above, but instead of Focus going to Product field, it went right back to this field, looking for ImmediateChange programming. It waits for key input, or else you need to manually move the focus somewhere else. So this is now the definition of my problem. Why is it flowing like this?
Product is the first field, is a combo box, is not ReadOnly.
This field is the second field , so don't understand why ThrowFocus("Product") would come here. I might understand that if Product was ReadOnly (like in Q&A movements).
Oh yes, one more thing. I need to add a note about the sample code that was provided.
The ThrowFocus lines need the quotes removed around the element name.
Change ThrowFocus("Product") to ThrowFocus(Product).
But the quotes are needed if using FormThrowFocus!
Thanks for the help so far, still trying to trace why ThrowFocus comes back to this same element vs. moving to Product.