Stepping through a script
While the script is paused, the buttons at the top of the editor (and their keys) move it on:
| Button | Key | What it does |
|---|---|---|
| Continue | F5 | Runs until the next breakpoint, or the end. |
| Step Over | F10 | Runs the line and pauses on the next one. A function the line calls runs whole. |
| Step Into | F11 | Pauses on the first line inside the function the line calls. On a line with no call, the same as Step Over. |
| Step Out | Shift+F11 | Runs the rest of the function and pauses on the line after the call. |
| Pause | F6 | Pauses a running script wherever it has got to, such as in a loop that never ends. |
Take this script, paused on line 6:
<fn name="greeting" params="name: string">
<let name="message" value=""Hello, {$name}!"" />
<return value="$message" />
</fn>
<let name="text" value="@greeting('Ada')" />
<echo value="$text" />fn greeting(name: string) {
$message = "Hello, {$name}!"
return $message
}
$text = @greeting('Ada')
echo $textStep Into pauses on line 2, inside greeting(), where Locals shows $name = 'Ada'. Step Over runs line 2 and pauses on line 3, where $message = 'Hello, Ada!' has appeared. Step Out runs the return and pauses on line 7, back at the top level, where Globals shows $text = 'Hello, Ada!'.
Stepping into a block function, such as the one ->map() calls, works the same way. It gets its own place on the Call Stack, named fn():
<let name="prices" value="[3, 8]" />
<let name="with_tax">$prices->map(fn(price) {
// Paused here, Locals shows $price = 3 the first time and $price = 8 the second.
$taxed = $price * 1.2
return $taxed
})</let>
<echo value="$with_tax" />$prices = [3, 8]
$with_tax = $prices->map(fn(price) {
// Paused here, Locals shows $price = 3 the first time and $price = 8 the second.
$taxed = $price * 1.2
return $taxed
})
echo $with_taxA one-line function written with =>, such as fn(price) => $price * 1.2, has no lines of its own to pause on, so stepping runs it whole.