repeat

Prev Next

Function Names

repeat

Synopsis

repeat (expression [, variable]) { statements } [ else { statements } ]
repeat (expression [, variable]) statement; else : statement

Description

repeat is a very simple loop function where a fixed number of repetitions is specified and the subsequent block or statement will be exececuted accordingly. An optional loop index can be picked up with the 2nd function parameter. Note that the loop cannot be influenced with the index variable, but the break and continue statements are available for this.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

OS differences

None

Parameter count

1..2

Parameters

No.TypeDescription
1
input
numeral Number of repetitions

Specify the number of repetitions

Default value: n/a
2
code
variable
:string
iterator value

This variable begins with 0 and ends with repetition count - 1. This variable is updated by this function in order to provide the value of the current parameter element. It is a copied value. Modifying this variable will not influence the loop

Exceptions

none

Examples

       repeat (3) echo(Hello);
       repeat ( 5, a[] )
       {
               print(a[],'  ');
       }
       echo;

Output

Hello
Hello
Hello
# Invalid Value #  1  2  3  4  
Try it yourself: Open LIB_Function_repeat.b4p in B4P_Examples.zip. Decompress before use.