1

I would like to implement a loop based on a specific condition in webMethods.

I would to execute some steps in a loop if a specific condition is true; for example the java code should be like this:

while(condition==true) {
    //some action
}

How can I do it?

Mikhail Tulubaev
  • 4,141
  • 19
  • 31
Deviltrigger
  • 63
  • 2
  • 12
  • You don't really need "condition == true" in your while loop. You can simply put just "condition" which defaults to true. – Ionut Necula Mar 03 '16 at 08:07

3 Answers3

2

You need to use a REPEAT loop that repeats on success. Within that, as the first step have a branch that leaves the loop if the while condition is not met.

I would advise putting a maximum loop count on the REPEAT to avoid runaway threads; if it should only loop a few times then a repeat limit of 99999 could save you a world of pain :)

enter image description here

Michael Lemaire
  • 746
  • 1
  • 6
  • 18
0

Actually you answered your own question. You can do a while loop as long as a boolean is true like so:

int i = 0;
while (condition) { //no need for '== true'
    i++
    if (i > 10) {
         condition = false;
    }
}

in that case i will return 11 and exit the while loop

0
             int intI = 0;
             bool bolStatus = true;
             while(bolStatus) 
             {
                //some action
                if (intI == 5)
                {
                   bolStatus = false;
                }
                intI ++;
              }
Archie
  • 1