Loops and repeated Commands

<< Click to Display Table of Contents >>

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

Loops and repeated Commands

BRK. - Break Loop

Previous Top Next


MiniRobotLanguage (MRL)

 

BRK. - Break Loop

Break Loop (jump to NEX. / OOP. and the Loop)

 

 

Intention

 

The BRK. command is used to exit a loop prematurely. Generally it will jump to the end of the Loop and exit the Loop.-

Alternatively you can give it a Line-Number or Label then it will jump to that Line instead - also ending the Loop perfectly.

 

Now there is another Loop which is designed to "Jump out" after a specified number of counts.

This is the "RRC. / JOR.-Loop". Its specially designed for such tasks.

 

It can be used with FOR. .. NEX. or DOL. .. OOP. - Loops

For example:

 

FOR.$$LHA|1|255

  FOR.$$LJA|1|255

    DBP.Looping: $$LHA-$$LJA

    IVV.$$LJA>3

      DBP.Was here.

      BRK.

      DBP.After BRK.

    EIF.

    DBP.Before Next

  NEX.

NEX.

ENR.

 

In this example, the inner loop will break when $$LJA is greater than 3, and the script will continue with the next iteration of the outer loop.

 

The Debug Window will show this (interrupted).

 

[23:28:42] Looping: 1-1

[23:28:42] Before NEX.

[23:28:42] Looping: 1-2

[23:28:43] Before NEX.

[23:28:43] Looping: 1-3

[23:28:43] Before NEX.

[23:28:44] Looping: 1-4

[23:28:44] Before BRK.   <- Inner Loop will be reseted here   

[23:28:45] Looping: 2-1

[23:28:45] Before NEX.

[23:28:45] Looping: 2-2

[23:28:46] Before NEX.

 

 

 

Syntax

 

 

BRK.[P1]

 

 

Parameter Explanation

 

P1 - [optional] Label or Line-Number, if omitted the Loop will be exited at the Loop-End (NEX. or OOP.).

 

 

 

 

Example

 

'***********************************

' BRK.-Sample

'***********************************

 FOR.$$LJA|1|255

    DBP.Looping: $$LJA

    IVV.$$LJA>3

      DBP.Was here.

      BRK.

      DBP.After BRK.

    EIF.

    DBP.Before Next

  NEX.

MBX.Ended.

ENR.

 

 

 

Remarks

 

 -

 

 

Limitations:

 

-

 

 

See also: