Re: Why are variables received by #(define-music-function) unbound in #{ #(scheme code here?) #}
"Marcus Macauley" <[EMAIL PROTECTED]> writes: > Either I've found a bug, or (more likely) I don't understand how > variables are passed between Lilypond and Scheme. > > Below is an example, where a #(define-music-function...) block > receives a variable, stringone. That variable seems to be accessible > (i.e. bound, if I have my terminology straight) in two places, but > not accesible (i.e. unbound) in the third place. > > 1. Accesible by Scheme code within #(define-music-function) but > outside of #{ #} block > 2. Accessible by Lilypond input within #{ #} block > 3. Not accesible by Scheme code within #{ #} block It is, use a $ sign. myfun = #(define-music-function (parser location num) (number?) #{ \override TextScript #'padding = #(* 2 $num) %% or: %% \override TextScript #'padding = #$(* 2 num) #}) \myfun #3 This is somewhat equivalent to the following: #(define some-variable 3) \override TextScript #'padding = #(* 2 some-variable) or, using the second version: #(define some-variable1 3) #(define some-variable2 (* 2 some-variable1)) \override TextScript #'padding = #some-variable2 nicolas ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Why are variables received by #(define-music-function) unbound in #{ #(scheme code here?) #}
Either I've found a bug, or (more likely) I don't understand how variables are passed between Lilypond and Scheme. Below is an example, where a #(define-music-function...) block receives a variable, stringone. That variable seems to be accessible (i.e. bound, if I have my terminology straight) in two places, but not accesible (i.e. unbound) in the third place. 1. Accesible by Scheme code within #(define-music-function) but outside of #{ #} block 2. Accessible by Lilypond input within #{ #} block 3. Not accesible by Scheme code within #{ #} block Why is this, and is there any way to pass a variable, received by define-music-function, to Scheme code within the #{ #} block? Thanks in advance, Marcus \version "2.9.23" function = #(define-music-function (parser location stringone) (string?) (let ((stringone (string-append stringone " foo"))) #{ % uncommenting the following line yields "ERROR: Unbound variable: stringone" %#(string-append stringone " bar") c1^\markup { $stringone } #})) \relative c'' { \function #"one" } ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user