lilypond-user
[Top][All Lists]
Advanced

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

Re: Properties outside of scores


From: Emilio Millan
Subject: Re: Properties outside of scores
Date: Sun, 29 Apr 2018 12:59:11 -0700 (MST)

Thanks for that, Andrew. Your suggestion and my own continued thinking made
me realize that scoping and evaluation order were the challenges I was
facing.

Scoping is tricky because I'm outside the usual scopes--Score, Staff and
Voice. But I am in a book (or bookpart) and so can set a property in the
relevant paper block.

As for evaluation order, since I want to use the property in a markup
function and also be able to set different property values at different
points in the file, I can write a markup function for setting those values.

Neither of these solutions are super-elegant, but both work so I include
illustrations below. In both cases, the property is named "xyzzy" and is
first set to 1, then to 2, with a markup function named "what-is-xyzzy"
illustrating that the value is as intended.

==== Solution 1 ====

\version "2.19.81"

#(define-markup-command (what-is-xyzzy layout props) ()
  (display (ly:output-def-lookup layout 'xyzzy))
  (newline)
  (interpret-markup layout props #{\markup {} #}))

\book {

  \bookpart {
    \paper {
      xyzzy = 1
    }
    
    \markup \what-is-xyzzy
  }

  \bookpart {
    \paper {
      xyzzy = 2
    }

    \markup \what-is-xyzzy
  }

}

==== Solution 2 ====

\version "2.19.81"

#(define xyzzy 0)

#(define-markup-command (set-xyzzy layout props value) (integer?)
   (set! xyzzy value)
   (interpret-markup layout props #{\markup {} #}))

#(define-markup-command (what-is-xyzzy layout props) ()
  (display xyzzy)
  (newline)
  (interpret-markup layout props #{\markup {} #}))

\markup \set-xyzzy #1

\markup \what-is-xyzzy

\markup \set-xyzzy #2

\markup \what-is-xyzzy

====

Regards,
Emilio



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html



reply via email to

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