[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Scheme global variables in Lilypond
From: |
Nick Payne |
Subject: |
Scheme global variables in Lilypond |
Date: |
Tue, 01 Jan 2013 14:50:09 +1100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
In the following lilypond code, why is the value of the scheme variable
dirn not being changed by the set! command in the updown function? The
updown function is called on the first line of beginStringNum, and here
returns the value DOWN, as shown by the TextSpanner appearing below the
staff, but when I use dirn further on in beginStringNum, for tweaking
the value of bound-details.right.text, the value that gets used is 1 and
not -1, as shown by the direction of the vertical line at the RH end of
the spanner.
If I open a Lilypond Scheme sandbox and do the same - create a global
variable and a function that sets it, then the variable has the new
value after the function call:
%================
\version "2.17.6"
#(define dirn 1)
#(define (updown grob)
(let ((ud (ly:event-property (event-cause grob) 'direction)))
(if (eq? -1 ud)
(begin
(set! dirn DOWN)
DOWN)
UP)))
beginStringNum = #(define-event-function (parser location strng)
(number?)
#{
\tweak direction #updown
\tweak bound-details.left.text \markup\bold\teeny\concat
{ \circle { \finger #(number->string strng) } \char ##x2006 }
\tweak font-shape #'upright
\tweak bound-details.left.stencil-align-dir-y #CENTER
\tweak dash-period #0.8
\tweak dash-fraction #0.6
\tweak thickness #0.8
\tweak bound-details.right.text \markup {
\draw-line #(cons 0 (/ dirn -2)) }
\tweak bound-details.left.padding #0.25
\tweak bound-details.right.padding #-1
\tweak bound-details.right-broken.padding #0.5
\tweak bound-details.left-broken.padding #2
\tweak bound-details.left-broken.text ##f
\tweak bound-details.right-broken.text ##f
\startTextSpan
#}
)
endStringNum = \stopTextSpan
\relative c {
\clef "treble_8"
c4_\beginStringNum 5 c c \times 2/3 { c8 c c\endStringNum }
}
%================
address@hidden ~ $ lilypond scheme-sandbox
GNU LilyPond 2.17.9
Processing
`/usr/local/lilypond/usr/share/lilypond/current/ly/scheme-sandbox.ly'
Parsing...
guile> (define x 1)
guile> (define (b y)
(set! x y))
guile> (display x)
1guile> (b 14)
guile> (display x)
14guile>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Scheme global variables in Lilypond,
Nick Payne <=