Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

10 Code Blocks

Code can be separated into blocks with line breaks to help make it more readable by grouping similar statements together. Think of code blocks as kind of like a paragraph when reading and writing.

/*
	An example script to show how everything works
*/

// declare all the necessary variables
var user = "Steve";
var greeting = "Hello, ";

// combine the variables
var output = greeting + user;

// do something with the output
Trace( output );

In the above example, lines 4, 8, and 11 are blank to make the different steps in the script easier to read. Any computer will simply ignore those empty lines. It’s going to strip all of the comments and empty lines and begin to read the code like this:

var user="Steve";var greeting="Hello, ";var output=greeting+user;Trace(output);