! Smart Package Robot 's Loops and repeated Commands

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Loops, and repeated action >

! Smart Package Robot 's Loops and repeated Commands

Smart Package Robot 's Loops and repeated Commands

Previous Top Next


 

Smart Package Robot 's Loops and repeated Commands

 

 

 

 

graphic

 

 

 

SmartPackage-Robot User Manual: Loop Operations Guide

 

 

1. Introduction

Welcome to the Loop Operations Guide for the Smart AI Package-Robot.
This Chapter provides detailed explanations of the different loop constructs available, ensuring efficient and effective use.

 

2. FOR-NEXT Loop

2.1 Basic Overview: The FOR-NEXT loop is a fundamental loop construct in Scripting.

 

2.2 Types of FOR-NEXT Loop:

Integer Loop: If the pre-processor detects only integer values in all parameters, the loop operates as an integer loop. This is the fastest loop type.

Floating-Point Loop: If any variable could potentially be a floating-point number, the loop operates in floating-point mode. This loop type is slower in comparison. The SmartPackage-Robot can handle precise float steps like 0.1 or 0.0553.

Direction: Loops can run forwards or backwards. For a reverse loop, specify a negative step value (e.g., Step -1). If the step is a positive 1, the last parameter (Step) can be omitted.

Loops with Variables: Loops using Variables tend to be slower then Loops with direct numeric values. This is because Variables need to be resolved from new at each iteration,
because they may have changed..

 

3. DOL.-OOP. (DO - Loop / WHILE - WEND / REPEAT - UNTIL)

3.1 Rejecting Loop: The condition for the loop is at the top. Depending on the condition, the loop either executes or skips entirely.

3.2 Accepting Loop: The loop's condition is at the bottom. The loop will always execute at least once. Depending on the subsequent conditions, it might repeat or terminate.

 

4. JOR. - Repeat Loop

This is a specialized loop construct designed for cases where one wishes to exit a loop after a certain number of actions.

 

5. Exiting and Iterating Loops

5.1 Previous Behavior: In earlier versions, if one exited a loop using the GOTO command, the loop remained active, waiting to complete its iterations.

5.2 Updated Behavior: With the latest update, the loop detects if one enters or exits. If you do not come from within the loop, it restarts, initializing all loop variables. This feature primarily impacts the FOR-NEXT loop.

 

5.3 BREAK and CONTINUE Commands: 

Both FOR-NEXT and DO-LOOP now support the BRK. (to exit) and CON. (to move to the next iteration) commands.

 

As before you can also change the Loop Parameters inside the Loop and these will be re-evaluated after every "Loop-Round".

While there are not many cases where this is needed, its possible.

 

 

Speed-Considerations:

 

Understanding the execution speed of loop commands in the Smart AI Package-Robot is vital for optimal performance.
This guide provides insights into how different inputs can affect the speed of your loops.

 

2. Factors Influencing Loop Speed

 

The execution speed of looping commands is influenced by the type of input:

 

Simple Numbers: Inputting straightforward numerical values will result in faster loop execution.

Formulas and Variables: Inputting formulas or variables that require calculation and evaluation will cause the loop to run slower, as these need to be processed before execution.

 

3. Types of "FOR. / NEX." Loops in Smart AI Package-Robot

 

The SmartPackage-Robot has two internal loop types:

 

3.1 Integer Loop:

 

Description: This loop deals solely with integer numbers.

Precision: It operates with 8-byte integers, which equate to 64-bit integers.

When It's Used: If your loop contains only integer numbers, the Smart AI Package-Robot will compile the Script to this loop type.

 

3.2 Floating Point Loop:

Description: This loop handles non-integer numbers or floating-point values.

Precision: It operates with extended precision to maintain accuracy for floating-point values.

When It's Used: If your loop contains variables, mathematical formulas, or any input that isn't a pure integer, the Smart AI Package-Robot will use this loop type.

 

 

clip0891

Nested FOR.-Loops. You can see the Speed Difference between INT-Numbers and Variables/FP-Loops.

 

 

clip0892

DOL. / OOP. Endless-Loop is generally very fast and much faster then FOR.-Loops.

 

 

clip0896

The RRC. / JOR. - Loop is also very fast due that it does not use external Variables. It only needs 35 Cycles per Round in this example.

 

clip0895

DOL. / OOP. Endless-Loop is generally very fast and much faster then FOR.-Loops.

 

 

 

clip0893

Here you can see Integer Loops and Loops with Formulas.

 

clip0894

Loops with mixed Parameters. In this case the Loop that used variables was only 173 Cycles (16 Mio. Cycles ~ 1 Second).