Breakpoints in scripts
Page in progress. |
Breakpoints when working with models are different from those used in scripts. |
Breakpoints of script editor allow you to pause code execution in the necessary place to analyse the program and search for errors. This function is available for .ngscript and .jl scripts.
To add a breakpoint to a code cell, hover the cursor over the left corner of a line of code. When a red dot appears, left-click on it to set the breakpoint:
To delete, edit or disable a breakpoint, right-click on the red mark and select the desired option:
A set breakpoint is displayed with a red dot in the left corner of the code line. When it is created, a list of all breakpoints is automatically opened at the bottom of the editor.
If you right-click on a red breakpoint, a menu for selecting the breakpoint type appears. A total of three types are available:
And three conditions required for breakpoints with conditions:
-
Expression - the breakpoint is triggered only if the specified expression is true.
-
Hit Count - triggers only after a line of code has been executed a certain number of times.
-
Wait for Breakpoint - allows you to pause code execution until another breakpoint is reached.
Let’s consider in detail what breakpoints there are and how they work with conditions:
-
Breakpoint
- This is a basic breakpoint that stops program execution when the code reaches the specified line. This breakpoint does not use conditions.
-
Condition Breakpoint
is a breakpoint with condition. It stops code execution only when the specified condition is met. For example, there is the following code:
for i in 1:10 println(i) end
To add a conditional breakpoint, right-click on a line of code, then select Add Conditional Breakpoint. In the menu that appears, enter the condition
i==5
in the Expression field and click Enter. The code will now stop wheni
becomes5
.->
-
Triggered Breakpoint
is an extended breakpoint with additional conditions. It stops execution only if another breakpoint has been activated. This is useful for complex debugging when code execution depends on other scripts. For example:
a = 0.5 # классическая Breakpoint b = 1.0 # Triggered Breakpoint, сработает после основной
To add a breakpoint with additional conditions, right click on a line of code, select Add Triggered Breakpoint. In the menu that appears, select the breakpoint that will trigger before the Triggered Breakpoint and click Ok:
Changing the conditions will also change the breakpoint type. For example, the Expression and Hit Count conditions are used to create a Condition Breakpoint ![]() ![]() |
To change the condition, right-click on an already created breakpoint and select the desired option:
The system will display a notification when you try to disable breakpoints with conditions or messages: