New Kojo Release (2.1, 140813), with support for Tracing and #includes

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) {

Now click on the Trace button 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)


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

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.


This entry was posted in News, Release. Bookmark the permalink.

2 Responses to New Kojo Release (2.1, 140813), with support for Tracing and #includes

  1. Ian Johnson says:

    I think you might have an error in the definition of square: I think forward(100) should read forward(n), hence using the parameter supplied. Otherwise, all squares drawn by this function will be the same size!

  2. Lalit Pant says:

    Thanks for catching that. Fixed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s