lilypond-user
[Top][All Lists]
Advanced

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

Re: how to define a boolean?


From: Mark Polesky
Subject: Re: how to define a boolean?
Date: Sat, 8 Aug 2009 10:48:35 -0700 (PDT)

Marc Hohl wrote:

> Sorry if this is a stupid question, but here im totally stuck:

Not a stupid question. This involves "parser variables" which are
giving us developers troubles, too! If you're curious, you can
follow this long thread:
http://lists.gnu.org/archive/html/lilypond-devel/2009-07/msg00921.html

> I need to define a boolean which is to be changed within a music-function
> and a stencil callback.

For the music-function you can do this:

% you can also do:
% mybool = ##f
#(define mybool #f)

myfunc =
#(define-music-function (parser location note) (ly:music?)
  (ly:parser-define! parser 'mybool #t)
  (let* ((mybool (ly:parser-lookup parser 'mybool))
         (color  (if mybool red blue)))
    #{
      \override  NoteHead #'color = $color
      $note
    #}))

The callback is a little trickier for me for the moment.
I'll get back to you.
- Mark



      




reply via email to

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