Subversion Repositories svn.mios

Rev

Rev 1186 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

HEADER 3 MIDIbox NG User Manual --- .NGR Script

<P CLASS=INFO><B><A HREF="midibox_ng_manual.html">Back to main page...</A></B></P>

<H1>MIDIbox NG</H1>
<H1>User Manual --- .NGR Script</H1>

<P CLASS=INFO>MIDIbox NG provides a (primitive) script language which allows to change values of control elements, to send free definable MIDI events, to output special text strings on LCD and to send debug messages to the MIOS Terminal. It even supports (limited) flowcontrol with if/elsif/else statements.</P>

<P CLASS=DESC>The idea for this script feature came up with the request to run a sequence of value changes (with delays in between) during power-on, resp. after a <A HREF="midibox_ng_manual_ngc.html">.NGC file</A> has been loaded. Over the time it has been enhanced by additional commands to cover other usecases, and meanwhile we even have some kind of flow control!</P>

<P CLASS=DESC>On a <A HREF="mbhp_core_stm32f4.html">MBHP_CORE_STM32F4</A>, the .NGR script will loaded from SD Card and then compiled into RAM to allow realtime execution of the commands within less than 1 mS! :-)<BR>
The <A HREF="mbhp_core_lpc17.html">MBHP_CORE_LPC17</A> module only allows direct execution from SD Card, which is much slower and therefore only allows sporadic interactive operations like special button functions (typically it will take 5..50 mS on this core!).</P>

<P CLASS=DESC>The .NGR file has the same name like the .NGC file. After power-on MIDIbox NG will load DEFAULT.NGC, and therefore also DEFAULT.NGR (if available).</P>


<H2> <IMG SRC="images/bullet.gif" ALT=""> Usecases </H2>

<P CLASS=DESC>Here a list of intended usecases:
<UL CLASS=CL>
  <LI>set values of control elements (LEDs, Buttons, LED Rings, Encoders, etc...) during startup with optional delays (for having some "blink" ;-).<BR>
      E.g. a nice sequence of patterns for LEDs and LED Rings by pushing a button to surprise your friends.
  <LI>send an informative message to the MIOS Studio terminal.<BR>
      E.g. to debug your .NGC setup (or the .NGR execution flow).
  <LI>set a control element value depending on conditions, which are derived from other control elements.<BR>
      E.g. to implement complex selections (if BUTTON:1 and BUTTON:2 is pressed the same time, do something special...)
  <LI>send a fully customizable MIDI messages, even multiple ones triggered by the same event.<BR>
      E.g. to select different patches on synthesizers which are connected to different MIDI ports and listen to different MIDI channels.
  <LI><B>MBHP_CORE_STM32F4 only (direct execution from RAM):</B> advanced event processing in realtime
</UL>

<P CLASS=DESC>If you know other interesting usecases which are not listed here, please let me know! :-)


<H2> <IMG SRC="images/bullet.gif" ALT=""> Calling the .NGR script </H2>

<P CLASS=DESC>The .NGR script can be called with following methods:
<UL CLASS=CL>
  <LI>it's started automatically with <I>^section == 0</I> after the corresponding .NGC file has been loaded. If you want to prevent the execution, please write following lines at the beginning of the .NGR file:
<TT><PRE style="margin-left:10px; font-size:8pt">
if ^section == 0
  exit
endif
</PRE></TT>
  <LI>it can be started from a Meta event which is defined in the <A HREF="midibox_ng_manual_ngc.html">.NGC file</A>, e.g.:
<TT><PRE style="margin-left:10px; font-size:8pt">
# start script with ^section == 1
EVENT_BUTTON id=1  type=Meta  meta=RunSection:1  button_mode=OnOnly
</PRE></TT>

Some configuration examples can be found under <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr1.ngc" TARGET="_blank">runscr1.ngc</A> (which calls <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr1.ngr" TARGET="_blank">runscr1.ngr</A>) and <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr2.ngc" TARGET="_blank">runscr2.ngc</A> (which calls <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr2.ngr" TARGET="_blank">runscr2.ngr</A>)

  <LI>it can be started from the MIOS Terminal with <I>run &lt;section&gt; &lt;value&gt;</I><BR>
The ^section variable will contain the value of <I>&lt;section&gt;</I><BR>
And the ^value variable will contain &lt;value&gt;</I><BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
run 1 127
</PRE></TT>
</UL>


<H2> <IMG SRC="images/bullet.gif" ALT=""> Commands </H2>

<P CLASS=DESC>Here a list of available commands:

<TABLE WIDTH="100%" BORDER=0 CELLSPACING=5 CELLPADDING=0>
  <TR>
    <TH WIDTH=150>Command</TD>
    <TH>Description</TD>
  </TR>
  <TR>
    <TD CLASS=TABCOLOR2><I>LCD &lt;string&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Prints an immediate message on screen while it's executed.<BR>
      All string control formats and directives are supported (see description of <A HREF="midibox_ng_manual_ngc.html">EVENT_* label parameter)</A>, which especially means that it's possible to clear the screen, and to jump to different cursor positions at different displays.<BR>
Examples:
<TT><PRE style="margin-left:10px; font-size:8pt">
# clear screen
LCD "%C"

# print message on first line of first LCD
LCD "@(1:1:1)Hello World!"

# print message on second line of first LCD
LCD "@(1:1:2)Second Line"

# print message on first line of second LCD
LCD "@(2:1:1)Second Display"
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>LOG &lt;string&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Sends a message to the MIOS Terminal.<BR>
                        Currently formatted messages are not supported, only static string (could change in future).
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
LOG "Hello World!"
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SEND &lt;midi-event&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Sends a MIDI event. The event definition typically contains:
      <UL CLASS=CL>
        <LI>the MIDI event type (NoteOff, NoteOn, PolyPressure, CC, ProgramChange, Aftertouch, Pitchbend, NRPN, SysEx)
        <LI>the MIDI port (USB1..USB4, OUT1..OUT4, OSC1..OSC4)
        <LI>the MIDI channel (1..16)
        <LI>one or more values depending on the event type
      </UL>
Examples:
<TT><PRE style="margin-left:10px; font-size:8pt">
#    type   port chn key  value
send NoteOn USB1   1  36  ^value
send NoteOn USB1   1  36  0

#    type         port chn key value
send Polypressure USB1   1  36 ^value

#    type port chn key  value
send CC   USB1   1  16  ^value

#    type          port chn value
send ProgramChange USB1   1 ^value

#    type       port chn value
send Aftertouch USB1   1 ^value

#    type      port chn value
send PitchBend USB1   1 ^value

#    type port chn number value
send NRPN USB1   1 0x0123 ^value

#    type  port stream
send SysEx USB1 0xf0 0x11 0x22 0x33 0x44 ^value 0xf7
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>EXEC_META &lt;meta-event&gt; [&lt;value&gt;]</I></TD>
    <TD CLASS=TABCOLOR2>Executes a meta event with an optional value.<BR>
      A list of available meta events can be found in the <A HREF="midibox_ng_manual_ngc.html">.NGC chapter</A>.
Examples:
<TT><PRE style="margin-left:10px; font-size:8pt">
if ^section == 0
  # wait until all values have been scanned (consider 2 seconds startup delay + a little bit margin)
  delay_ms 2500
  
  # now capture the AINSER values
  exec_meta RetrieveAinserValues

  # and dump out values
  exec_meta DumpSnapshot
endif
</PRE></TT>

or

<TT><PRE style="margin-left:10px; font-size:8pt">
if ^section == 1
  exec_meta SetSnapshot 1
  exec_meta DumpSnapshot
endif
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>TRIGGER &lt;id&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Triggers a control element with the given <I>&lt;id&gt;</I>, so that it sends out it's MIDI event and prints it's label on LCD.<BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
# send the MIDI event of the first three pots connected to the AINSER module
trigger AINSER:1
trigger AINSER:2
trigger AINSER:3
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET &lt;id&gt; &lt;value&gt;</I><BR>
                                  <I>SET ^&lt;variable&gt; &lt;value&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Similar to TRIGGER, but it also changes the value of the control element.<BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
# turn on the first 3 LEDs connected to the DOUT module:
set LED:1 127
set LED:2 127
set LED:3 127
</PRE></TT>

    The <I>SET</I> command also allows to change the variables: ^section, ^value, ^bank (will change the EVENT banks). And it allows to change the global variables ^dev, ^pat, ^bnk, ^ins, ^chn.<BR>
    Examples:
<TT><PRE style="margin-left:10px; font-size:8pt">
# turn on the first 3 LEDs connected to the DOUT module:
set ^section 1
set ^value 2
set ^bank 3
set ^pat ENC:1
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>CHANGE &lt;id&gt; &lt;1|0&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Similar to <I>SET</I>, but won't trigger a MIDI event.<BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
set BUTTON:1 42
</PRE></TT>
will change the button value to 42, but the MIDI event which has been specified for this button won't be generated.
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET_RGB &lt;id&gt; &lt;red&gt;:&lt;green&gt;&lt;blue&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Similar to the <I>rgb</I> parameter in the .NGC file, this command allows to change the brightness levels for the three LED layers of a LED matrix. All three values range from 0..15.<BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
# it's assumed, that a DOUT_MATRIX is configured for all three layers,
# and that led_emu_id_offset is set to 1001, so that the LEDs are
# individually accessible via LED:1001, LED:1002, ...

# set the RGB levels for multicolour LEDs connected to a DOUT_MATRIX

# Red
set_rgb LED:1001 15:0:0

# Green
set_rgb LED:1002 0:15:0

# Blue
set_rgb LED:1003 0:0:15

# Yellow
set_rgb LED:1004 15:15:0

# Cyan
set_rgb LED:1005 0:15:15

# Magenta
set_rgb LED:1006 15:0:15

# Orange
set_rgb LED:1007 15:8:0

# White
set_rgb LED:1008 15:15:15

# now turn on the LEDs by setting the maximum value
set LED:1001 127
set LED:1002 127
set LED:1003 127
set LED:1004 127
set LED:1005 127
set LED:1006 127
set LED:1007 127
set LED:1008 127
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET_HSV &lt;id&gt; &lt;h&gt;:&lt;s&gt;&lt;v&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Sets the hue/saturation/value colour code of a WS2812 based RGBLED. H ranges from 0..359 (grad); saturation and value (brightness) range from 0..100 (percentage)<BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
# red
set_hsv RGBLED:1 0:100:25

# green
set_hsv RGBLED:2 120:100:25

# blue
set_hsv RGBLED:3 240:100:25
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET_LOCK &lt;id&gt; &lt;1|0&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Allows to lock/unlock the MIDI receiver of an EVENT.<BR>
    Examples: with
<TT><PRE style="margin-left:10px; font-size:8pt">
      set_lock ENC:1 1
</PRE></TT>
    the encoder with hw_id=1 won't change its value on incoming MIDI events anymore (it still can be changed manually when it's moved).<BR>
    With:
<TT><PRE style="margin-left:10px; font-size:8pt">
      set_lock ENC:1 0
</PRE></TT>
    the encoder will be unlocked, so that it will change the value on a matching incoming MIDI event again (default).
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET_ACTIVE &lt;id&gt; &lt;1|0&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Can be alternatively used instead of the bank mechanism to activate/deactivate events, e.g. if the same events should be activated in multiple banks under certain conditions. A usage example can be found under:
     <UL CLASS=CL>
       <LI><A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Fmultibnk.ngc" TARGET="_blank">multibnk.ngc</A>
       <LI><A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Fmultibnk.ngr" TARGET="_blank">multibnk.ngr</A>
     </UL>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET_NO_DUMP &lt;id&gt; &lt;1|0&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Allows to change the "no_dump" flag which specifies if an EVENT_xxx should be sent during a DumpSnapshot.
     This feature can be used to handle different snapshot setups.</TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>SET_MIN &lt;id&gt; &lt;1|0&gt;</I><BR><I>SET_MAX &lt;id&gt; &lt;1|0&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Sets the minimal/maximal value of an event (in the .NGR file specified with range=&lt;min&gt;:&lt;max&gt;.<BR>
       Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
# let the button toggle between 63 and 65
set_min BUTTON:1 63
set_max BUTTON:1 65
</PRE></TT>
    </TD>
  </TR>


  <TR>
    <TD CLASS=TABCOLOR2><I>DELAY_MS &lt;ms&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Delays the execution of the script for the given number of milliseconds.<BR>
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
set LED:1 127
delay_ms 100
set LED:1 0

set LED:2 127
delay_ms 100
set LED:2 0

set LED:3 127
delay_ms 100
set LED:3 0
</PRE></TT>
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>LOAD &lt;setup&gt;</I></TD>
    <TD CLASS=TABCOLOR2>Switch to another setup (.NGC, .NGS, .NGR, ... files)
    </TD>
  </TR>

  <TR>
    <TD CLASS=TABCOLOR2><I>IF</I><BR><I>ELSIF</I><BR><I>ELSE</I><BR><I>ENDIF</I></TD>
    <TD CLASS=TABCOLOR2>See special flow control chapter below.
    </TD>

  <TR>
    <TD CLASS=TABCOLOR2><I>EXIT</I></TD>
    <TD CLASS=TABCOLOR2>Stops the execution of the .NGR script.
Example:
<TT><PRE style="margin-left:10px; font-size:8pt">
# don't do anything during startup
if ^section == 0
  exit
endif
</PRE></TT>
    </TD>
  </TR>
</TABLE>


<H2> <IMG SRC="images/bullet.gif" ALT=""> Expressions </H2>

<P CLASS=DESC>All values specified with the SET/SEND/IF/etc... command are handled as expressions which can be:
<UL CLASS=CL>
  <LI>a constant decimal value from -16384..16384
  <LI>a constant hexadecimal value from 0x0..0x3fff
  <LI>a constant octal value from 0..037777
  <LI>a control element <I>hw_id</I>, e.g. BUTTON:1, ENC:1, AINSER:1, etc... (see next section about IDs)
  <LI>a control element <I>id</I>, e.g. (id)BUTTON:1, (id)ENC:1, (id)AINSER:1, etc... (see next section about IDs)
  <LI><I>^section</I>: this variable can be passed from the Meta event or "run" terminal command. It's 0 when a .NGC file.
  <LI><I>^value</I>: the item value when the script is called from a Meta event.
  <LI><I>^bank</I>: the current bank
</UL>

<P CLASS=DESC>More ^ variables can be implemented on request.


<H2> <IMG SRC="images/bullet.gif" ALT=""> IDs </H2>

<P CLASS=DESC>Whenever a control element is addressed with it's id (e.g. BUTTON:1, LED:1, AINSER:1, ENC:1 (see also <A HREF="midibox_ng_manual_ngc.html">.NGC chapter</A>), the parser will search for a matching <B>hardware id</B> (<I>hw_id</I>) by default.</P>

<P CLASS=DESC>This means for example, that a
<TT><PRE style="margin-left:50px; font-size:8pt">
set LED:1 127
</PRE></TT>
command will change the value of the first LED connected to the first pin of a DOUT shift register (or emulated LED matrix LED if <I>emu_led_id_offset</I> is used in the DOUT_MATRIX configuration).</P>

<P CLASS=DESC>If no EVENT_LED has been defined in the .NGC file, the hardware will be directly accessed via a virtual event like known from <I>fwd_id</I>.

<P CLASS=DESC>If multiple EVENT_LED are assigned to the same <I>hw_id</I>, but to different <I>bank</I>s, only the EVENT item of the currently selected bank will be accessed.

<P CLASS=DESC>Sometimes you want to access an element based on it's <I>id</I> independent from the current bank selection. Or the specified <I>id</I> doesn't match with the assigned <I>hw_id</I>. For such cases, it's possible to cast this type with the <I>(id)</I>:
<TT><PRE style="margin-left:50px; font-size:8pt">
# set EVENT_LED id=1 directly without considering the current bank selection
set (id)LED:1 127
</PRE></TT>

<P CLASS=DESC>For completeness reasons, it's also possible to cast <I>(hw_id)</I>, although this type is used by default:
<TT><PRE style="margin-left:50px; font-size:8pt">
# set EVENT_LED id=??? hw_id=1
set (hw_id)LED:1 127

# is doing the same like:
set LED:1 127
</PRE></TT>


<P CLASS=DESC>The casting method is also useful if you want to read a value of a control element independent from the bank selection, such as:
<TT><PRE style="margin-left:50px; font-size:8pt">
if (id)BUTTON:20 != 0
  log "BUTTON:20 is pressed"
endif
</PRE></TT>


<H2> <IMG SRC="images/bullet.gif" ALT=""> Operations </H2>

<P CLASS=DESC>Some basic mathematical operations are supported. They have to be surrounded with square-brackets ([...]).</P>

<P CLASS=DESC>Syntax: <I>[&lt;left-operand&gt;&lt;operator&gt;&lt;right-operand&gt;]</I></P>

<P CLASS=DESC>Examples:
<UL CLASS=CL>
  <LI><I>set LED:2000 [LED:2000 + 1]</I><BR>
      will increment the value stored in LED:2000
  <LI><I>set LED:2000 [LED:2000 - 1]</I><BR>
      will decrement the value stored in LED:2000
</UL>
</P>

<P CLASS=DESC>Note that nested operations are supported as well, such as:
<UL CLASS=CL>
  <LI><I>send CC USB1 1 [LED:2000 + [LED:2001 + [LED:2002 + LED:2003]]]</I>
</UL>
</P>

<P CLASS=DESC>More examples can be found in <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr5.ngc" TARGET="_blank">runscr5.ngc</A> and <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr5.ngr" TARGET="_blank">runscr5.ngr</A></P>

<P CLASS=DESC>Support operators:
<UL CLASS=CL>
  <LI><I>+</I>: addition
  <LI><I>-</I>: substraction
  <LI><I>*</I>: multiplication
  <LI><I>/</I>: divide
  <LI><I>%</I>: modulo
  <LI><I>&amp;</I>: logical AND
  <LI><I>|</I>: logical OR
  <LI><I>^</I>: logical XOR
</UL>
</P>



<H2> <IMG SRC="images/bullet.gif" ALT=""> Flow Control </H2>

<P CLASS=DESC>With the IF/ELSIF/ELSE/ENDIF commands it's possible to define condition under which blocks of commands are executed. Nested IF conditions are allowed, the max. depth is 16!</P>

<P CLASS=DESC>A condition consists of a left and right value + a condition in the middle:
<LI><I>&lt;left expression&gt; &lt;condition &lt;right expression&gt;</I></P>

<P CLASS=DESC>Examples:
<TT><PRE style="margin-left:50px; font-size:8pt">
if ^section == 1

  log "Section is 1"
endif
</PRE></TT>

or:

<TT><PRE style="margin-left:50px; font-size:8pt">
if ^section == 1
  # initial patches for my synths:
  send CC OUT1 1 0 0
  send ProgramChange OUT1 1 0

  send CC OUT1 2 0 0
  send ProgramChange OUT1 2 0

  send CC OUT1 3 0 0
  send ProgramChange OUT1 3 0

  send CC OUT2 1 0 0
  send ProgramChange OUT2 1 0

  exit
endif


if ^section == 2
  # alternative patches for my synths:
  send CC OUT1 1 0 0
  send ProgramChange OUT1 1 21

  send CC OUT1 2 0 0
  send ProgramChange OUT1 2 1

  send CC OUT1 3 0 0
  send ProgramChange OUT1 3 75

  send CC OUT2 1 0 0
  send ProgramChange OUT2 1 0x10

  exit
endif
</PRE></TT>

or:

<TT><PRE style="margin-left:50px; font-size:8pt">
if ^section == 1
  if BUTTON:1 > 0
    if BUTTON:2 > 0
      log "BUTTON:1 and BUTTON:2 are pressed"
    endif
  endif
endif
</PRE></TT>

<P CLASS=DESC>Supported conditions are: <I>==, !=, &lt;, &lt;=, &gt;, &gt;=</I>.<BR>
Logical combinations are not supported.</P>


<H2> <IMG SRC="images/bullet.gif" ALT=""> Loops (resp. restarting)</H2>

<P CLASS=DESC>Loops are not directly supported. There is neither a "goto"/"jump" command, nor a "do" or "while" loop, to keep the parser algorithm simple.

<P CLASS=DESC>But with following trick it's possible to restart the .NGR script with the <I>RunSection:&lt;section&gt;</I> meta event. As you can see, this even allows to start the .NGR file with a different ^section value.

Usage example:
<TT><PRE style="margin-left:50px; font-size:8pt">
# don't do anything during startup & patch load
if ^section == 0
  exit
endif

# loop this section as long as BUTTON:2000 is active
# Note that this button has been configured for toggle mode!
if ^section == 1
  log "Section 1 called"

  # do this

  # and that

  # maybe with some delays:
  delay_ms 100

  # and finally:
  if (id)BUTTON:2000 != 0
    LCD "@(1:1:2)loop running "
    log "Retriggering section 1"
    exec_meta RunSection:1
  else
    LCD "@(1:1:2)loop finished"
    log "Finished."
  endif
  exit
endif
</PRE></TT>

<P CLASS=DESC>The files can be found under <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr3.ngc" TARGET="_blank">runscr3.ngc</A> and <A HREF="http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr3.ngr" TARGET="_blank">runscr3.ngr</A>.

<P CLASS=DESC>For the case, that you (unintentionally) created an endless loop, it's possible to stop the execution with the "runstop" command in the MIOS Terminal. In addition, it's possible to generate a <I>RunStop</I> meta event with a dedicated button.


<H2> <IMG SRC="images/bullet.gif" ALT=""> Limitations </H2>

<P CLASS=DESC>The capabilities are still limited, mainly caused by RAM size limitations of the <A HREF="mbhp_core_lpc17.html">MBHP_CORE_LPC17</A>. Following limitations have to be considered:
<UL CLASS=CL>
  <LI>please don't expect a script language which is so powerful like for example <A HREF="http://www.eluaproject.net" TARGET="_blank">eLua</A>! Although it would be possible to run eLua on a LPC1769, the available RAM isn't sufficient to satisfy the needs for MIDIbox NG in parallel!
  <LI>It's currently not possible to declare and set customized variables. Limited capabilities could be available in future, but they will consume some RAM!
  <LI>It's not possible to combine conditions in an IF statement (e.g. with && or ||) because this would blow up the parser too much. If this is desired, use nested IF statements on an AND condition, or multiple IF statements on an OR condition.
</UL>

FOOTER