I’m pleased to announce a new release of Kojo. This release includes a couple of big features:
Program Tracing
This feature is based on work done by Sami Jaber during GSOC’13.
Here’s how you use Tracing. Copy the program below into the Script Editor:
def square(n: Int) {
repeat(4) {
forward(n)
right()
}
}
clear()
square(100)
Now click on the Trace button
in the Script Editor Toolbar.
This will run the program in Trace mode and bring up the Program Trace window:

The new window shows you a trace of all the important command/function Calls and Returns in your program. If you click on a trace element, the line in the script editor which generated that element gets highlighted (see below), and a marker appears in the drawing canvas showing you the contribution of that element to the drawing inside the canvas:

Tracing works well for non-visual programs, too. Try it with this program:
def factorial(n: Int): Int =
if (n == 0) 1 else n * factorial(n - 1)
factorial(4)
Hopefully, that is enough information to get you started with tracing. I’ll do a more detailed post on this topic later…
#includes – for code reuse
With this feature, you can make scripts refer to other scripts by using #includes. So, for example, you might define a function in a file called script1.kojo:
def sum(n1: Int, n2: Int) = n1 + n2
And then, in another script, you can start using the sum function like this:
// #include script1.kojo
sum(2,3)
This allows you to start writing libraries of useful commands/functions that can be reused across scripts.
Many thanks to Björn Regnell for his contributions to the #include feature and his feedback on the Tracing feature.
As always, the new version is available from the Kojo Download Page.
Enjoy!