"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

Reply via email to