Am 05.02.2013 11:07, schrieb David Kastrup:
Jan-Peter Voigt <[email protected]> writes:

Hi Urs,

you can write a music-function that conditionally includes files.
I use a function to include a file, if it exists. The if statement can
of course also test for a option with ly:get-option.
\version "2.16.0"

includeIfExists =
#(define-music-function (parser location file)(string?)
    (if (file-exists? file)
        (ly:parser-include-string parser (format "\\include \"~A\"\n" file)))
    (make-music 'SequentialMusic 'void #t))
Any reason you don't use define-void-function here?  Saves the somewhat
weird make-music call and is likely usable in more places.

Thanks for this tip.
Update attached

Now I define a variable for the type of score I have (one- or multi-system or multi-page) and call the function in the master file, like:

   #(define-public score-type "multi-page-example")
   \include "layout/output-mode.ily"

If -dexample is present the appropriate stylesheet is loaded according to score-type, otherwise the default 'a4-standalone' style sheet is used.


Thanks both of you.
Best
Urs


\version "2.16.0"

#(define-public score-type "one-system-example")

includeOutputMode =
#(define-void-function (parser location)()
   (cond
        ((ly:get-option 'example)
             (ly:parser-include-string parser 
                 (string-append "\\include \"layout/" 
                     (string-append score-type ".ily\"\n"))))
        (else (ly:parser-include-string parser "\\include \"layout/a4-standalone.ily\"\n"))
   )
)

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

Reply via email to