Skip to content

Commit

Permalink
Merge pull request #189 from notengrafik/pr/doexport-filename-argument
Browse files Browse the repository at this point in the history
Move filename dialog to DoExport() and return filename
  • Loading branch information
ahankinson authored Oct 11, 2021
2 parents 176bb01 + cda0050 commit 630d7d1
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions src/Run.mss
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
function Run() {
//$module(Run.mss)

// do some preliminary checks
if (Sibelius.ProgramVersion < 7000)
if (not InitGlobals(null))
{
Sibelius.MessageBox(_VersionNotSupported);
return False;
return null;
}

if (Sibelius.ScoreCount = 0)
{
Sibelius.MessageBox(_ScoreError);
return False;
}
DoExport(null);

} //$end


function GetExportFileName () {
// get the active score object
activeScore = Sibelius.ActiveScore;

Expand All @@ -26,26 +24,42 @@ function Run() {
activePath = Sibelius.GetDocumentsFolder();
}

if (not InitGlobals(null))
{
return false;
}

// Ask to the file to be saved somewhere
filename = Sibelius.SelectFileToSave('Save as...', activeFileName, activePath, 'mei', 'TEXT', 'Music Encoding Initiative');

if (filename = null)
return filename;
} //$end


function DoExport (filename) {
//$module(Run.mss)

// Argument filename is optional and will be determined automatically if
// `null` is passed in instead. The filename is also returned so the
// caller can then work with.

// do some preliminary checks
if (Sibelius.ProgramVersion < 7000)
{
Sibelius.MessageBox(_ExportFileIsNull);
Sibelius.MessageBox(_VersionNotSupported);
return False;
}

DoExport(filename);

} //$end
if (Sibelius.ScoreCount = 0)
{
Sibelius.MessageBox(_ScoreError);
return null;
}

function DoExport (filename) {
//$module(Run.mss)
if (null = filename)
{
filename = GetExportFileName();
if (null = filename)
{
Sibelius.MessageBox(_ExportFileIsNull);
return null;
}
}

if (not Self._property:_Initialized)
{
Expand Down Expand Up @@ -97,4 +111,6 @@ function DoExport (filename) {

// clean up after ourself
libmei.destroy();

return filename;
} //$end

0 comments on commit 630d7d1

Please sign in to comment.