Followup:

When I try to _use_ that function from another Scheme function I get a strange error message, although the generated files are right:

Attached you'll find a .ly file with a function that calls writeScoreOddEven.

When I run it I get this message at the very end of the process:

Converting to `./writeScoreOddEven-UsageTest-even.pdf'...

/home/uliska/Github/openLilyLib/OLLincludes/compilationTools/writeScoreOddEven-UsageTest.ly:13:4 <0>: In expression ((#<procedure embedded-lilypond #> parser " \\writeScoreOddEven #1 \\score { $score } " ...)):

/home/uliska/Github/openLilyLib/OLLincludes/compilationTools/writeScoreOddEven-UsageTest.ly:13:4 <1>: Wrong type to apply: #<unspecified>
Exited with return code 1


Is there something wrong with my calling syntax?

Best
Urs

Am 15.02.2013 13:30, schrieb Urs Liska:
Am 15.02.2013 13:24, schrieb Jan-Peter Voigt:
o dear, thunderbirds always destroys any formatting done in frescobaldi ...
here my working example as an attachment.

;-)

Just for the record: Attached is my final version of the function (that will go into openLilyLib ...). I (re-)added a parameter to specify the starting page number of the oddpage version. (For my use it isn't relevant because the page numbers are printed by the enclosing latex document, but of course to be of more generic use one has to have this possibility).

Best and thank you again
Urs


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

\version "2.16.0"

\include "writeScoreOddEven.ily"

compileScore = 
#(define-void-function (parser location score)
   (ly:score?)
   ; this compiles the file(s) but returns with an error message
   (#{ \writeScoreOddEven #1 \score { $score } #})
   ; the following syntax doesn't work either
   ;(writeScoreOddEven 1 score)
   )

% Make results visible
\paper { print-first-page-number = ##t }

% Call the function
\compileScore \score { 
    \relative c'' {
      c b a g c1
    }
  }
\version "2.16.0"

% Helper function
% get the basename of the main file
mybasename = #(ly:parser-output-name parser)

% create two pdf files from the given score,
% one starting with an odd, the other starting with an even page.
% - Arg1 is the number of the odd starting-page
%  (the even starting-page will be oddpage + 1
% - Arg2 is the score to be printed.
% 
% The oddpage version will keep the original name
% while the evenpage version will be appended '-even'
writeScoreOddEven =
#(define-void-function (parser location oddpagenum score)
   (number? ly:score?)
   (let ((book #{ \book { \score { $score } } #}))
   ; process with first-number 1
   (ly:output-def-set-variable! (ly:book-paper book) 'first-page-number 
oddpagenum)
   (ly:book-process book #{ \paper {} #} #{ \layout {} #} mybasename)
   ; process with first-number 2
   (ly:output-def-set-variable! (ly:book-paper book) 'first-page-number (+ 
oddpagenum 1))
   (ly:book-process book #{ \paper {} #} #{ \layout {} #} (format "~A-even" 
mybasename))
   ))

%{ Usage example:
   
% Let the first page number be visible (to see the result)
\paper {
  print-first-page-number = ##t
}

% Do any configuration
\header {
  % ...
}

% \include "some-music.ily"

% Call the function
\writeScoreOddEven #11 \score { 
    \relative c'' {
      c b a g c1
    }
  }
  
%}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to