Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

4 Statements

A statement is an instruction written in JavaScript to tell the computer to do something. Statements are a core building block of JavaScript both in and out of Scripter. Just about anything to be done can be broken down into simple steps and translated into JavaScript statements for execution.

The following example is a valid script containing a single statement which will execute when the Run Script button is clicked:

Trace("Hello, world!");

This tells Scripter’s MIDI Engine to write "Hello, world!" to the Interactive Console:

***Creating a new MIDI engine with script***

Evaluating MIDI-processing script...
Script evaluated successfully!
Hello, world
>

In almost all cases, multiple statements will be needed to do anything of value in Scripter:

var say_hello = "Hello, world!";
Trace(say_hello);

In this example, the phrase “Hello, world!” is placed in a variable, say_hello and then the variable is used to output to the console.