---
url: >-
  /statelake/scripting-reference/functions-and-procedures/program-control-functions/cancelexecution.md
---

# CancelExecution

The **CancelExecution** procedure cancels the execution of the **Map** (or **Custom Script**) immediately after the event script has finished processing.

Any code lines in the script following this **CancelExecution** line will still be executed. If the **Action** has one or more **Action Steps** after the **Map** or **Custom Script**, the subsequent step(s) will still execute.

To stop the execution of any subsequent or remaining lines in the script that follow the **CancelExecution** line, use this procedure in tandem with the **Exit** procedure. Please review [Exit](/statelake/scripting-reference/functions-and-procedures/program-control-functions/exit) for more details.

The status of the **Action** is not affected (for **Logs** or notifications), and the **Log** will be considered to have been successfully processed - so the **Log** colour will be **GREEN**. Even if the **Exit** procedure is called, the **Log** will be **GREEN**.

A similar procedure is **StopExecution**.

**Declaration**: Procedure CancelExecution;

Examples follow.

```pascal
procedure OnMapEvent(var Value:Variant);
var aInt : integer;
begin
  aInt := 15;
 if aInt> 10 then
 begin
    LogInfo('This is the 1st line before CANCEL.');
    LogInfo('This is the 2nd line before CANCEL.');
    LogInfo('Next line will CANCELEXECUTION. . . .');

    CancelExecution;                        //subsequent lines will ALL execute;
    LogInfo('This is the 1st line after CANCEL.');
    LogInfo('This is the 2nd line after CANCEL.');
    LogInfo('Next line will EXIT . . . .');

    Exit;                                   //subsequent lines will NOT execute;
 //processing has now ceased and nothing further will execute
    LogInfo('This is the 1st line after EXIT.');
    LogInfo('This is the 2nd line after EXIT.');
 end;

end;
```
