1. Home
  2. Docs
  3. Workflow
  4. WorkFlow Control
  5. While

While

System.Activities.Statements.While

  • While activity is used to execute a specific process repeatedly, while a specific condition is met.
  • In this activity, the condition is evaluated before the body of the loop is executed.
  • This activity is used to browse through array indices or step through a list of items by increment counters.

 Properties

      Misc

  • Condition (Activity<Boolean>) –Define a condition/an expression.
  • DisplayName (String) – To set a meaningful name according to the user.

 Example

To use a While activity, create an automation that increments an integer variable 1 to 50, and writes all the numbers to a Notepad document.

  • Create a sequence.
  • Create an integer variable, counter, with the default value of 1.
  • Add a While
  • In the Condition field, type counter < 50. This condition means the body of the loop will be repeated until the value of the counter variable is going to be bigger than 50.
  • Add an Assign activity in the Body section of the While
  • Add the counter variable in the Properties panel, in the To field of the Assign
  • Type counter + 1 in the Value field, which increments the value of the counter with one.
  • Add a WriteFile activity under the Assign
  • Type the path of a Notepad document in between quotation marks in the Filename
  • Type “The counter value is”+Tostring+”.”.
  • Run the process.
  • After the execution of the process, open the notepad document specified there all the numbers between 1 and 50 are written.