Scripter Javascript Tutorial
javascriptmusiclogicscripterbookexcerpttutorial59 Conditional Branching
MDN: Control Flow and Error Handling: Conditional Statements
Events come in a variety of types and just about any manipulation of events will require some kind of decision making about what actions to perform in certain situations. There are 4 types of branching in JavaScript, all applicable to Scripter:
iffor when a block of code is to be executed when the specified condition is true.elsefor when the specified condition is false.else ifto specify a new condition when the previous one is false.switch, which is a variation onif...else if.
Conditional branching is critical to working with events being passed
into HandleMIDI() and when using TimingInfo
process blocks to understand which bar and division the playhead is
currently in.