Jaa


BREAK Function (Report, XMLport)

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

Syntax

CurrReport.BREAK  
CurrXMLPort.BREAK  

Remarks

BREAK causes the current trigger to end. When used inside a loop, such as a WHILE-DO or REPEAT-UNTIL construction, BREAK interrupts the loop and causes the current trigger to end.

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

Tip

You can also use the C/AL BREAK Statement to exit an iteration or loop. The difference is that the BREAK statement does not terminate the trigger. It just exits the loop.

Example

This example of code in a trigger on 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.
MyVar := 0;  
REPEAT  
  MyVar := MyVar + 1;  
  IF MyVar = 5 THEN  
    CurrReport.BREAK;  
  MESSAGE(Text000,MyVar);  
UNTIL Myvar = 10;  
MESSAGE('After REPEAT-UNTIL loop'); //This statement is never called.  

When you run the previous code, the loop will end when MyVar is 5 and the execution of the current trigger ends. Statements after the loop are not executed.

See Also

Report Data Type
XMLport Data Type
C/AL BREAK Statement