Undefined properties and function
Writing my first plugin. I have this code:
console.log("curScore: " + curScore)
console.log("\ttypeof: " + typeof curScore)
console.log("\tversion: " + curScore.version)
console.log("\tcomposer: " + curScore.composer)
console.log("\ttitle: " + curScore.title)
console.log("\tsubtitle: " + curScore.subtitle)
console.log("\tfileName: " + curScore.fileName)
console.log("\tmeasures: " + curScore.measures)
curScore.appendMeasures(11)
curScore.close()
which outputs:
Debug: curScore: Ms::PluginAPI::Score(0x75a9190)
Debug: typeof: object
Debug: version: undefined
Debug: composer:
Debug: title: The Spruce
Debug: subtitle: undefined
Debug: fileName: undefined
Debug: measures: undefined
Debug: Exception TypeError: Property 'close' of object Ms::PluginAPI::Score(0x77d4840) is not a function
- I have the composer, title, and subtitle text defined in the file, yet they do not show up here. Why not?
- Why is version undefined?
- The appendMeasures() works.
- It says close is not a function but I see it defined here:
https://musescore.org/en/handbook/developers-handbook/plugin-developmen…
What is happening here?
Comments
I'm no expert on the plugin framework, but I know a decent amount about MuseScore internal architecture. I'm guessing you only added text for title, etc, but didn't actually define them in the metadata (File / Score Properties). For the version, my guess is that info doesn't get generated until you save - it's meant to convey the version of MuseScore used to save the file. No real idea about close().
In reply to I'm no expert on the plugin… by Marc Sabatella
Thanks for you reply (as always). You are correct about the 'composer' in the metadata. However, the metadata does not have entries for subtitle, fileName, measures so these are still a mystery to me, as is version, since the score has been saved many times and close()
Except for composer none of these are standard metatags and as such undefined unless they had been manually added (to File > Score properties). See https://musescore.org/en/handbook/3/score-properties#default-tags
In reply to Except for composer none ot… by Jojo-Schmitz
I'm new at this, but it doesn't make sense to me what there isn't a 1-1 correspondence between File > Score Properties and the class Score properties.
Any thoughts on the close() function?
You are most likely not developing a plugin for MuseScore 1.
So use the correct reference for the current version, such as https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…