New Midi remote how to access multiple pages on a touch screen

Here is the script in question proposed:

/**

  • MIDI Remote Script for Cubase 14 - Page management via NRPN
  • Created for Sherlock by 14bitMIDI
  • Author: ChatGPT
    */

// Initialization
var currentPage = 1; // Default page
var totalPages = 18; // Total number of pages

function detectNRPN(midiMessage) {
if (midiMessage.isChannelController()) {
var status = midiMessage.getChannel();
var data1 = midiMessage.getData1();
var data2 = midiMessage.getData2();

if (status === 15) { // Channel 16 in hexadecimal (BF)
if (data1 === 99) { // NRPN MSB
global.nrpnMSB = data2;
}
if (data1 === 98) { // NRPN LSB
global.nrpnLSB = data2;
}
if (data1 === 6) { // Data Entry MSB
global.dataEntryMSB = data2;
}
if (data1 === 38) { // Data Entry LSB
global.dataEntryLSB = data2;
changePage(global.nrpnMSB, global.nrpnLSB);
}
}
}
}

function changePage(msb, lsb) {
var newPage = lsb - 55; // Example of offset (adjust according to Sherlock’s exact values)
if (newPage >= 1 && newPage <= totalPages) {
currentPage = newPage;
console.log("Current page: " + currentPage);
updateMappings();
}
}

function updateMappings() {
// Remove old mappings
pageManager.clear();

// Add new mappings according to the active page
for (var i = 0; i < 196; i++) {
var button = pageManager.createButton(i, "Button " + (i + 1));
button.midiBinding().bindToNote(0, i + (currentPage - 1) * 196);
button.setLabel("Page " + currentPage + " - Button " + (i + 1));
}
}

// Register the MIDI detection function
host.addMidiInput().setMidiCallback(detectNRPN);
console.log(“MIDI Remote Script successfully loaded! :control_knobs:”);

If anyone can confirm that this is possible

because I don’t know how to code and I know that soon we will certainly no longer be able to use generic peripherals
and in this case I could no longer use future Cubase updates.