Johan Vromans <jvromans <at> squirrel.nl> writes: > > Hi, > > In a template file I want to check if a particular identifier has been > defined, and act accordingly.
These two functions should help. (Suggestions for improvement would be appreciated.) You will either need to define your optional music to be empty when it is not required, as in this example, or provide a function to create empty music if it is not already defined. (It's hard to tell from your example what your needs are.) \version "2.11.52" #(define-public (music-empty? m) (let ((void-music (ly:music-property m 'void))) (or (and (not (null? void-music)) void-music) (and (null? (ly:music-property m 'element)) (null? (ly:music-property m 'elements)))))) ifThenElse = #(define-music-function (parser location if-music then-music else-music) (ly:music? ly:music? ly:music?) (if (music-empty? if-music) else-music then-music)) aNotes = \relative c' { e1 } bNotes = \relative c' { c1 } cNotes = { } \book { \score { \ifThenElse \aNotes { \time 2/2 \partcombine \aNotes \bNotes } { \time 1/1 \bNotes } } \score { \ifThenElse \cNotes { \time 2/2 \partcombine \cNotes \bNotes } { \time 1/1 \bNotes } } } _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user