[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why are variables received by #(define-music-function) unbound in #{
From: |
Nicolas Sceaux |
Subject: |
Re: Why are variables received by #(define-music-function) unbound in #{ #(scheme code here?) #} |
Date: |
Mon, 16 Oct 2006 22:57:58 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
"Marcus Macauley" <address@hidden> 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