Scripter Javascript Tutorial
javascriptmusiclogicscripterbookexcerpttutorial76 Script Organization
Because scripts need to contain all code in a single file, good high-level organization is key, even for small scripts. Many of the Logic-supplied scripts are organized like this:
A basic script template would then look like this:
/*
Name:
Author(s):
Purpose:
Information:
Change History:
YY_MM_DD_V_##_##_##: Started script
*/
/*
SCRIPTER GLOBAL VARIABLES
*/
var NeedsTimingInfo = true;
var PluginParameters = [];
/*
CUSTOM GLOBAL VARIABLES
*/
/*
SCRIPTER FUNCTIONS
*/
function HandleMIDI(event) {
event.send();
}
function ProcessMIDI() {
var timingInfo = GetTimingInfo();
}
function ParameterChanged(param, value) {
}
/*
CUSTOM FUNCTIONS
*/
/*
PARAMETER CONTROL MANAGEMENT
-> Remember to update ParameterChanged()
*/
Using the above as a template means that no matter how large or small the script ends up being, anyone familiar with the organization know where a particular item is supposed to be, which can be a huge time saver while developing and going back to old scripts. This template will be used as the example in the following sections.