Dear javascript wizards,
I have this block of code which works perfectly fine:
for (var i = 0; i < PushEncodersA; ++i)
{
var displayInsertsParameterTitle=allInsertParameters[i].mOnTitleChange =
(function (activeDevice, activeMapping, value, print) {
var i2=this.i
var dspl="0x"+(11+i2)
var row = 0x00
var columns = 7
var dataDisplay = [0xf0, 0x00, 0x00, 0x66, 0x14, dspl, row];
var dataDisplayReset = [0xf0, 0x00, 0x00, 0x66, 0x14, dspl, row]
for (var j = 0, len = columns; j < len; ++j) {
dataDisplay.push(print.charCodeAt(j))
dataDisplayReset.push(0x00)
}
dataDisplayReset.push(0xF7)
dataDisplay.push(0xF7)
midiOutput.sendMidi(activeDevice, dataDisplayReset)
midiOutput.sendMidi(activeDevice, dataDisplay)
}).bind({i})
}
Since I’m using a big part of that code (the function) at other points of my script again and again I tried to put it into a variable and call that. Well, I don’t get en error report but the code like this just does not work:
var printDspl = (function (activeDevice, activeMapping, value, print) {
var i2=this.i
var dspl="0x"+(11+i2)
var row = 0x00
var columns = 7
var dataDisplay = [0xf0, 0x00, 0x00, 0x66, 0x14, dspl, row];
var dataDisplayReset = [0xf0, 0x00, 0x00, 0x66, 0x14, dspl, row]
for (var j = 0, len = columns; j < len; ++j) {
dataDisplay.push(print.charCodeAt(j))
dataDisplayReset.push(0x00)
}
dataDisplayReset.push(0xF7)
dataDisplay.push(0xF7)
midiOutput.sendMidi(activeDevice, dataDisplayReset)
midiOutput.sendMidi(activeDevice, dataDisplay)
}).bind({i})
//Display Inserts Parameter Title
for (var i = 0; i < PushEncodersA; ++i)
{
var displayInsertsParameterTitle=allInsertParameters[i].mOnTitleChange = printDspl
}
Has anybody got a solution? Many thanks in advance!
Emre