/[svn]/doc/docbase/instrument_scripts/nksp/01_nksp.html
ViewVC logotype

Diff of /doc/docbase/instrument_scripts/nksp/01_nksp.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3311 by schoenebeck, Wed May 31 23:21:42 2017 UTC revision 3312 by schoenebeck, Sat Jul 15 17:04:05 2017 UTC
# Line 1500  end on Line 1500  end on
1500        use the preprocessor instead for such things. And like stated above,        use the preprocessor instead for such things. And like stated above,
1501        there are certain things which you can only achieve with the preprocessor.        there are certain things which you can only achieve with the preprocessor.
1502      </p>      </p>
1503            <p>
1504          Since it is quite common to switch a script between a development version
1505          and a production version, you actually don't need to wrap all your
1506          <code>message()</code> calls into preprocessor statements like in the
1507          previous example. There is actually a built-in preprocessor dedicated to
1508          perform that task much more conveniently for you. So the previous example
1509          can be simplified like this:
1510        </p>
1511        <code>
1512    { Enable debug mode, so show all debug messages. }
1513    SET_CONDITION(DEBUG_MODE)
1514    
1515    { If our user declared condition "DEBUG_MODE" is not set ... }
1516    USE_CODE_IF_NOT(DEBUG_MODE)
1517      { ... then enable this built-in condition to disable all message() calls. }
1518      SET_CONDITION(NKSP_NO_MESSAGE)
1519    END_USE_CODE
1520    
1521    on init
1522      declare const %primes[12] :=  ( 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 )
1523      declare $i
1524    
1525      message("This script has just been loaded.")
1526    
1527      USE_CODE_IF(DEBUG_MODE)
1528      $i := 0
1529      while ($i < num_elements(%primes))
1530        message("Prime " & $i & " is " & %primes[$i])
1531        $i := $i + 1
1532      end while
1533      END_USE_CODE
1534    end on
1535    
1536    on note
1537      message("Note " & $EVENT_NOTE & " was triggered with velocity " & $EVENT_VELOCITY)
1538    end on
1539    
1540    on release
1541      message("Note " & $EVENT_NOTE & " was released with release velocity " & $EVENT_VELOCITY)
1542    end on
1543    
1544    on controller
1545      message("MIDI Controller " & $CC_NUM " changed its value to " & %CC[$CC_NUM])
1546    end on
1547        </code>
1548        <p>
1549          You can then actually also add <code>RESET_CONDITION(NKSP_NO_MESSAGE)</code>
1550          at another section of your script, which will cause all subsequent
1551          <code>message()</code> calls to be processed again. So that way you can
1552          easily enable and disable <code>message()</code> calls of entire individual
1553          sections of your script, without having to wrap all <code>message()</code>
1554          calls into preprocessor statements.
1555        </p>
1556    
1557      <h2>What Next?</h2>      <h2>What Next?</h2>
1558      <p>      <p>
1559        You have completed the introduction of the NKSP real-time instrument        You have completed the introduction of the NKSP real-time instrument

Legend:
Removed from v.3311  
changed lines
  Added in v.3312

  ViewVC Help
Powered by ViewVC