DoLoop

(Engine-Level Function)

Description: Executes a do-while loop in a script.
Returns: Nothing
Usage: Script only.
Function Groups: Logic Control
Related to: Case | Cond | IfElse | IfThen | WhileLoop
Format: DoLoop(Function1, Function2, …, Condition)
Parameters:  
Function1, Function2, …   
Required. Any expression or statement. This is the body of the loop. All of the Function parameters are executed in order prior to testing the Condition parameter.
Condition   
Required. Any logical expression for the loop control. As long as this is true, the loop will repeat.
Comments: The Function parameters are executed at least once, then Condition is checked. If Condition is true, the Function parameters are executed and Condition is executed again. This repeats until Condition is false or Invalid.

While the DoLoop statement has its place in VTScada programming, it should be noted that if working with arrays, speed can be enhanced by a factor of approximately 5 through the use of array processing functions. Refer to Array Functions for further details.

Example:

  If 1 Main;
  [
    I = 0;
    DoLoop(
      X[I] = Concat("Pump ", I);
      I++;
    { while I is less than 10 }
      I < 10;
    );
  ]

This loop executes 10 times, assigning a text string to the next element of the array "x" on each iteration.