BREAK Function (Dataport, Report, XMLport)

Exits from a loop or a trigger in a data item trigger of a dataport, report, or XMLport.


BREAK

When used inside a loop, such as a WHILE-DO or REPEAT-UNTIL construction, BREAK interrupts the loop. Execution continues with the statement that immediately follows the loop.

When used outside a loop, BREAK causes the current trigger to end.

Compare this with the QUIT Function (Dataport, Report, XMLport).

This example of code in a report object requires that you create the following variable and text constant in the C/AL Globals window.

Variable name DataType

MyVar

Integer

Text constant ENU value

Text000

The variable is now %1.

REPEAT
  MyVar := MyVar + 1;
  IF MyVar = 5 THEN
    CurrReport.BREAK;
  MESSAGE(Text000,MyVar);
UNTIL Myvar = 10

When you run the preceding code, the loop will end when MyVar is 5.

Community Additions

ADD
Show: