MIDI Remote Surface code

Is there anyone who can check why the attache script triggers an error? Or does anyone know how to debug it?
AnyKeyCubaseController.zip (3.1 KB)

Hi,

Could you attach a screenshot of the error Cubase shows, please?


I could have guessed upfront that a screenshot would be helpful ;p

It’s a parse error. Probably in 1 of the class files but I have no clue on how to debug this and staring at it for 2 hours didn’t help finding it. Can also not trace it with console messages since the code is not executed due to the parse error.

console.log(‘Start’)

/**

  • @type {cCubaseController}
    */
    //import objCubaseController from ‘./cCubaseController’

class cCubaseController {
constructor() {
}

}

var objCubaseController = new cCubaseController()

console.log(‘Instantiated’)

//objCubaseController.fInitialize()

console.log(‘Ready’)

This code also fails. It seems that using the class keyword triggers the error.

Aaaaaarghh, it’s the javascript version. Cubase uses ES5, however, the Cubase API script uses class definitions and those were introduced in ES6.

So ES5 is supported, but the API uses class definitions that are not supported in ES5. That’s weird right?

Not necessarily. It’s basically about what was thought suitable for both comms.

Now, there are few type of errors here.

I see functions returning String instead of Number, defining types without first importing them from the other modules, assigning new to non-voids, there’s even a function where you handle the strMessage var, then push to an undefined objMessage. Finally I see an export (ES6) while as you correctly understood, should be module.exports, and so on.

Not sure if you copy-pasted the code, still I would suggest that you start writing your script in ONE file. You can “beautify” your code-structure later if needed, there’s no reason to dive into classes for a start. Make your life with debugging easier, and at the same time, other users can be more helpful too, it’s not easy to follow a file-to-file eye-debugging.
However, if you insist on this type of structuring, consider using debugging tools from inside visual studio code, an example is node.js which has to be setup properly first.

2 Likes

Thanks for your feedback.

I put it all in 1 file with some amount of globals and it works now.

I never did any extensive javascript coding so I learned a lot.

2 Likes