Re: Immediacy of Do Until - not until the end of the loop?

By the way, I'm using 3 level nested loop to emulate the actions.

DO A = System Condition

     If this many errors so far, then Exit Run

Do Until (B) = This test iteration continues until all off the specified data sheet is done (or exited)

Do Until (C) = Run this data sheet until x case is complete and I just need to go to the next line.

   Select Case <action>

       Case <action value>

          During this case a condition may occur so I want to go to the test iteration (Loop B) or datasheet row (Loop C) without executing things outside the End Select.

         And depending on the case, I probably want to go run my rule checks.

        After those rule checks, all will either continue as normal, or require me to exit the datasheet and go back to the test iteration.


In other words, I'm trying to set my "Do Until" variable dependent on the loop level I want to return to.

   i.e. next iteration (Loop B) or next row (Loop C)

      goToLoopB - initialized as 0. Changed to 1 when needed

     LoopC - initalized as 1. (This can be an Exit Do, I know., but I end up with so many Exit Dos, that maintainability by the next author will be insanity.)



  • First, what does this have to do with ALM/Quality Center, which is the topic of this forum? Is this maybe about a UFT/QTP test script - which would be more appropriately posted in the forum for that product?

    Second, Do-Until loops will not exit the moment the condition becomes true. The code is linear, not event driven. The condition will not be evaluated until the line of code that does that evaluation is executed, linearly, as the last line in the loop.

    If you want to evaluate your condition at the beginning of the loop instead of the end, use a While structure.

    In any looping structure (Do, While, For, etc), if you want to exit a loop from within the middle of the loop, then you have to add code to check your condition variable in the middle of the loop, and then use an Exit command to exit the loop prematurely.

  • I see what you mean about the where to post.  Sorry about that!

    It's an existing QTP script with actions that the customer wanted to modify, and rather than running macros in Word for every test report, I figured I could to it in ExpertView...  That's why I thought it was QTP related.

    Sorry, but thank you for the answer!!