Error in plugin when using readScore()

• Dec 1, 2023 - 15:51

This code saves the current score as .mscx; reads it back as a text file; processes the contents with some regex; writes back the text file then finally opens this new score.

Everything works but the readScore() step generates 2 warning messages. Any idea what's wrong?

readScore.png

The FileIO setup looks like this:

FileIO.png


Comments

In reply to by yonah_ag

batch_convert.qml has this interesting info:

thisScore = readScore(fileFullPath, true);

            // Make sure we have a valid score
            // Rem: MS fails a reading a score ("readScore" above) if the score is already opened. 
            // => So we check if a score with the same path is already opened.
            if (!thisScore) {
                console.log("Failed to read "+fileFullPath+".\nChecking if it is already open.");
                var opened=scores;
                for(var i=0;i Checking if curScore is this file: "+score.path);
                    if (score.path.toLowerCase()===fileFullPath.toLowerCase()) {
                        thisScore=score;
                        isCurScore=true;
                        break;
                    }
                }
                console.log("==> And it "+((!thisScore)?"is not":"is"));
            }

In reply to by elsewhere

I've now added the missing boolean parameter and assigned a variable called thisScore but it produces a different warning id:

readScore2.png

The modified .mscx score does actually open in MuseScore but this warning must be telling me that something is not quite right. I'll see if I can find more examples in other plugins.

In reply to by elsewhere

Thanks! that fixes the warning. :-)

One minor side-effect is that that the original mscz score tab is marked as changed (with a *). I tried adding cmd("undo") but to no effect, presumably because this tab has lost focus to the newly loaded mscx file. Can I re-activate the original tab so that I can apply the undo? It's not a big deal but would be nice.

Do you still have an unanswered question? Please log in first to post your question.