--- doc/docbase/instrument_scripts/nksp/01_nksp.html 2017/07/15 16:24:59 3311 +++ doc/docbase/instrument_scripts/nksp/01_nksp.html 2017/07/15 17:04:05 3312 @@ -1500,7 +1500,60 @@ use the preprocessor instead for such things. And like stated above, there are certain things which you can only achieve with the preprocessor.

- +

+ Since it is quite common to switch a script between a development version + and a production version, you actually don't need to wrap all your + message() calls into preprocessor statements like in the + previous example. There is actually a built-in preprocessor dedicated to + perform that task much more conveniently for you. So the previous example + can be simplified like this: +

+ +{ Enable debug mode, so show all debug messages. } +SET_CONDITION(DEBUG_MODE) + +{ If our user declared condition "DEBUG_MODE" is not set ... } +USE_CODE_IF_NOT(DEBUG_MODE) + { ... then enable this built-in condition to disable all message() calls. } + SET_CONDITION(NKSP_NO_MESSAGE) +END_USE_CODE + +on init + declare const %primes[12] := ( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 ) + declare $i + + message("This script has just been loaded.") + + USE_CODE_IF(DEBUG_MODE) + $i := 0 + while ($i < num_elements(%primes)) + message("Prime " & $i & " is " & %primes[$i]) + $i := $i + 1 + end while + END_USE_CODE +end on + +on note + message("Note " & $EVENT_NOTE & " was triggered with velocity " & $EVENT_VELOCITY) +end on + +on release + message("Note " & $EVENT_NOTE & " was released with release velocity " & $EVENT_VELOCITY) +end on + +on controller + message("MIDI Controller " & $CC_NUM " changed its value to " & %CC[$CC_NUM]) +end on + +

+ You can then actually also add RESET_CONDITION(NKSP_NO_MESSAGE) + at another section of your script, which will cause all subsequent + message() calls to be processed again. So that way you can + easily enable and disable message() calls of entire individual + sections of your script, without having to wrap all message() + calls into preprocessor statements. +

+

What Next?

You have completed the introduction of the NKSP real-time instrument