Variables allow objects to be assigned to names during the parse stage. To assign a variable, use
name=
value
To refer to a variable, precede its name with a backslash:
`\
name'. value is any valid Scheme value or any of
the input-types listed above. Variable assignments can appear at top
level in the LilyPond file, but also in \paper
blocks.
A variable can be created with any string for its name, but for accessing it in the LilyPond syntax, its name must consist of alphabetic characters only, and may not be a keyword of the syntax. There are no restrictions for naming and accessing variables in the Scheme interpreter,
The right hand side of a variable assignment is parsed completely before the assignment is done, so variables may be redefined in terms of its old value, e.g.
foo = \foo * 2.0
When a variable is referenced in LilyPond syntax, the information it points to is copied. For this reason, an variable reference must always be the first item in a block.
\paper { foo = 1.0 \paperIdent % wrong and invalid }
\paper { \paperIdent % correct foo = 1.0 }
This page is for LilyPond-2.0.1 (stable-branch).