ok, I tried it out myself now and I can confirm these are 2 bugs :
- arithmetic functions on variables should always keep the value between 0 and 127, also in case of "overflow"
- when using a "while" loop within a switch statement, the "case" condition is not correctly evaluated on statements following the while loop.
Following version works correctly, because it doesn't have statements after the "while" :
(for your info : the "default:" statement within a switch statement is optional, so if it doesn't contain any commands you can omit it)
TRIGGER_CLICK AllNotesOffPanic =
{
switch($Device)
{
case "Hammond":
SendMidi Hammond CtrlChange $HammondAllSoundsOff 127
break
case "Nord":
SendMidi Nord NoteOff 127 0
$currentnote=127
while ($currentnote > 0)
{
$currentnote--
SendMidi Nord NoteOff $currentnote 0
}
// don't add any more commands here...
break
}
}