# Loop

The loop allows you to repeat a chain of actions (blocks) multiple times while counting the number of iterations of the loop, recording the current count in a special variable (specified in the "Loop" property), which can then be used in other blocks.

Upon the first entry into the block, the value of the variable from the "Loop" property is set to the "Initial Value" (![](https://3212714295-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FI0zUnKkOuy6lWt7DZ46u%2Fuploads%2Fgit-blob-c805b2c8c8952318aa374facb8eb491f3106c117%2Fimage%20\(174\).png?alt=media)), and then the execution of the scenario continues towards the "Loop" exit of this block (into the so-called "loop body").

As soon as the execution of the scenario reaches this block again, the value of the "Loop" variable will increase by the value of "Step", and the transition will occur again towards the "Loop" exit. Once the value of the "Loop" variable becomes greater than or equal to the "Final Value", the execution of the scenario will continue towards the lower exit of the block. Don't forget to connect the exit of the last block in the loop body to the entry of this block or any of the preceding blocks.

<table data-header-hidden><thead><tr><th width="247" valign="top"></th><th width="311" valign="top"></th></tr></thead><tbody><tr><td valign="top">Initial Value</td><td valign="top">[Number] The initial value of the variable from the Loop property, which will be assigned to this variable at the beginning of the loop.</td></tr><tr><td valign="top">Final Value</td><td valign="top"><p>[Number] The final value of the variable from the Loop property.</p><p>The loop iterations will be executed as long as the value of the Loop variable is less than the value specified in this property.</p></td></tr><tr><td valign="top">Step</td><td valign="top"><p>[Number] The increment step of the value of the variable from the Loop property in each iteration of the loop.</p><p>The step can have a negative value, which is useful when the Initial Value is greater than the Final Value, and counting needs to be done in reverse.</p></td></tr><tr><td valign="top">Loop</td><td valign="top">[Number] The variable that will store the current value of the loop. For example, if: <code>Initial Value = 0</code>, <code>Final Value = 7</code>, and <code>Step = 2</code>, then the loop values will sequentially be <code>0</code>,<code>2</code>,<code>4</code>,<code>6</code>.</td></tr><tr><td valign="top">Error Handling Level</td><td valign="top"><p>Select the error handling level. Possible values:</p><ul><li>"Default" - by default;</li><li>"Ignore" - errors are ignored;</li><li>"Handle" - errors are handled.</li></ul><p>If "Default" is selected, the value of the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Exit Direction</td><td valign="top"><p>Select the exit direction from the block in case of an error. Possible values:</p><ul><li>"Default" - by default;</li><li>"Right" - to the right;</li><li>"Bottom" - down.</li></ul><p>This property allows you to define the exit direction in case of errors for blocks that do not contain the "If Error" connector (for example, the "Condition" block).</p><p>If "Default" is selected, the value of the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Message Level</td><td valign="top"><p>Select the message level that blocks will output during operation. Possible values:</p><ul><li>"Default" - by default;</li><li>"Release" - output is disabled;</li><li>"Debug" - outputs main information;</li><li>"Detailed" - outputs detailed information.</li></ul><p>If "Default" is selected, the value of the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Error Text</td><td valign="top">[Text] Returns detailed information about the error in case of incorrect execution of the block's work.</td></tr></tbody></table>
