lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conditional include


From: Urs Liska
Subject: Re: conditional include
Date: Tue, 05 Feb 2013 11:15:16 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

Am 05.02.2013 11:07, schrieb David Kastrup:
Jan-Peter Voigt <address@hidden> 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


Attachment: conditionalInclude.ly
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]