lilypond-user
[Top][All Lists]
Advanced

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

Re: Passing a variable into a scheme function? (need syntax of)


From: John Mandereau
Subject: Re: Passing a variable into a scheme function? (need syntax of)
Date: Tue, 01 Aug 2006 22:02:51 +0200

Rick Hansen (aka RickH) wrote:
> How can I pass a variable into the "magstep" function?
> 
> The following fails on a parser error, the log ends with "parsing...".  I
> would like to be able to pass a scaling factor into my template along with
> all the notes variables.  When I hard-code -3 into the template it works
> fine, but when I try to use the variable called "varMyScaleFactor" it fails. 
> I'm not a scheme programmer, so this should be a simple syntax question (I
> hope).
> 
> 
> % Song file follows...
> \include "english.ly"
> 
> varMyScaleFactor = #-3
> varMyNotes = \relative c {
> c4 c c c |
> c4 c c c |
> c4 c c c |
> c4 c c c |
> }
> varMyTitle = "My Fish Freddy"
> 
> 
> 
> % Template file follows...
> 
> #(set-global-staff-size 20)
> 
> \header {
>         title = \varMyTitle
> }
> 
> <<
>      \new Staff
>      \with
>      {
>          fontSize = \varMyScaleFactor
>          \override StaffSymbol #'staff-space = #(magstep \varMyScaleFactor)
>      }
>      {
>          \clef treble
>          \varMyNotes
>      }
>  >>
> 

Inside Scheme code - here in the magstep call -, use no backslash, the
variable name is enough:

\override StaffSymbol #'staff-space = #(magstep varMyScaleFactor)


The rest of your code is correct; note that you can also define
varMyScaleFactor like this:

#(define varMyScaleFactor -3)

Cheers,
-- 
John Mandereau <address@hidden>





reply via email to

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