Creating files with MIDI Remote - possible?

Is it possible to create files with MIDI Remote and read from them as needed?

It would be enough if those files are simple text files. And for the path it would be ok if such files are placed where the script is located.


I believe you can use the standard JavaScript library to read/write a file.

What is your use case?

I want to write various parameters to a file that I create during a Cubase session with my script. When I reload the script, I want to read these parameters back in.


Do you know the MIDI Remote scripts are global (not per project)? Does your idea still make sense?

Yes, in my case (the script is 6250 lines big at the moment) this makes sense.
Do you have a little piece of code for to write to files which is tested?

I tested some code I found, but nothing works with the MIDI Remote JavaSpript Interpreter from Cubase.


This is the code, I’m using in another application, which uses the same interpreter (if I’m not mistaken). I have to admit, I haven’t tested it in MIDI Remote…

function saveFile(path) {
	var jsPath = path + '.js'

	var jsFile = new File(jsPath, 'write', 'TEXT')
	jsFile.eof = 0 // To make the file empty, if there are data already

	if (jsFile.isopen) {
		jsFile.writeline("Hello World!")

		console.log('JS file has been written', jsPath)
	} else {
		console.log('Could not create JS file: ', jsPath)

function readStringFile(filePath) {
	var memstr = ''
	var maxchars = 800
	var sourceTextFile = new File(filePath, 'read');
	if (sourceTextFile.isopen) {
		while(sourceTextFile.position < sourceTextFile.eof) {
			memstr += sourceTextFile.readstring(maxchars)
	} else {
		console.log('Error\n while reading file:', filePath)

	return memstr

for this row:

var jsFile = new File(jsPath, 'write', 'TEXT')

I get the following error message in Cubase:
ReferenceError: indentifier ‘File’ undefined

That means, that the JavaScript Interpreter in Cubase, which there is implemented
to handle MIDI Remote don’t know the type / function ‘File’.

Of course I realize that the JavaScript Interpreter in Cubase can’t do everything, so the question was directed from the start to people who have already managed to work with files from the script.


Sorry, as I mentioned, I haven’t tried.

thanks anyway for your attempt to help. :slightly_smiling_face:

Hi Martin, as you already know, MR uses ES5, and this unfortunately means that file write is not included. It would be great if Steinberg eventually adds support for this, because there are indeed use cases, especially device settings that a user chooses to alter in some scripts.

Hi, note that as Martin already stated, the MR is a global entity. At the end of the day, storing session data would then require from you to implement a restore mechanism based on the project opened. This can be done by for example assigning a dummy track containing such info, but globally it’s not feasible with pure MR use.
Your best bet for write (and in some cases properly read) files, is to build a small external utility and connect it to your midi remote script by virtual ports. However, this added overhead can trouble some users. If it’s for your own use, it will be perfectly fine, I do this all the time for my own work.

EDIT: Here’s a feature-request which would probably save us some efforts: Midi Remote activeDevice states persistent storage


Yes, this is a good idea. :grinning: