Debug tracer
This tab allows you to inspect the state of variables at the time your code is executed. This can be very useful for fixing a script that no longer works or simply during the debugging phase.

In order to use the debugging functionality, you need to place a debug instruction within your code using the following syntax: debug(parameter : text). When the code is processed and the debug instruction is reached then an entry will be made in the Debug Tracer tab, with the content of the parameter as title and underneath a structure of all variables available at that moment with their current values.
The Ninext panel must be open: with the panel closed, the debug points reached are not recorded. The Debug Tracer tab, on the other hand, does not need to be in the foreground.
To try the examples on this page, paste them into the Console and run them: the Debug Tracer immediately shows their debug points. The trash can, at the top right of the Tracer, clears the list.
Note: you can add any variable of special interest to your text string to see the value instantly in the Debug Tracer tab, ensuring that the type is text though! (e.g. debug("Debug point 1 : " + Variable1); )
If we look closely at the tab, we can see that each time the debug instruction is executed, a new line is created.
This line contains the name of the debug point, which is the text passed as a parameter to the debug function, for example: debug("my debug point").
At the beginning of the line, the time elapsed since the previous debug line is also displayed. This helps evaluate the performance of the code (see below). The first line always has the value “start.”
This debug line itself contains one line per variable visible at this point of the script: the variables declared before the debug instruction, the variable of a loop, and even the one whose declaration is under way, which is then “void”. Each variable line includes the name, type, value, and a snippet of the code where the variable is declared.

Expanding, copying, opening
Values are displayed as in the Console:
- a list, a record, an object, a reference or a text containing JSON unfolds with a click on its arrow;
- when you hover over a line, a button appears that copies its value; on the debug point's line, it copies the whole trace;
- an underlined value designates a record: a click opens it in Ninox.
Usage in loops
By placing a debug inside a loop, it allows you to see the state of the variables at each iteration of the loop. You can also see the time spent on each loop iteration. In the example below, the delay mostly stays under 1 ms.
let a := select Customer
let d := for i in a do
debug("for each customer");
i.'first name' + " " + i.'last name';
end;
debug("all customers");
d;
But if we add an instruction that is costly in terms of execution time, such as the “select” instruction, we can see that the time between each iteration increases significantly.
let a := select Customer
let d := for i in a do
let e := select Invoice where Customer = i;
debug("for each customer");
i.'first name' + " " + i.'last name' + " " + sum(e.TOTAL);
end;
debug("all customers");
d;
By placing a debug instruction before and after a block of script, you can measure the total execution time of the script :
debug("start of script");
let a := select Customer
let d := for i in a do
i.'first name' + " " + i.'last name';
end;
debug("end of script");
d;
