Hi Jan-Peter,

thank you very much. This example function was actually accessible for me [other than a similar function in lalily, which is just that little amount more complex ...].
I tweaked it to my needs as can be seen in the attachment.
It makes a decision depending on the presence of a -dexample option and
- if it isn't present it includes a 'standalone' stylesheet (for better readability during development) - if it is present it includes a stylesheet whose name is flexibly defined by the function's argument.

Hey, my first working and usable Scheme function :-)

Best
Urs


Am 04.02.2013 20:01, schrieb Jan-Peter Voigt:
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.


Best, Jan-Peter



On 04.02.2013 16:48, Urs Liska wrote:
Hi list,

I don't know if I _could_ find this info myself, but I'm quite puzzled about it and so I'd rather ask:

I would like to \include files depending on the presence (or absence) of certain command-line options.
Basically it should do something like:
- if option A is present then \include A.ily
- if option B is present then \include B.ily
- if none of them is present then \include default.ily

Ideally this would be a function that I can define in a separate file and only include this file in my main .ly file.

Background is: A, B and default are style sheets that style the score according to their context (e.g. standalone score <--> part of a book or draft <--> final mode). While I know how to deal with this decision by writing both includes in the file and comment out the one I don't need ATM, I would highly prefer to be able to do this with a command line option, so I can run a script on a potentially large number of files. (The only other workaround I can think of now is to let the script actually rewrite the .ly file before compiling it, but I think that's not really elegant).

I'd be grateful about any hints or solutions.
Best
Urs

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user



_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

\version "2.16.0"

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

\includeOutputMode "one-system-example"
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to