+@seealso
+Music Glossary:
+@rglos{system}.
+
+@node Saving typing with variables and functions
+@subsection Saving typing with variables and functions
+
+@cindex variables
+@cindex variables
+
+By this point, you've seen this kind of thing:
+
+@lilypond[quote,verbatim,ragged-right]
+hornNotes = \relative c'' { c4 b dis c }
+
+\score {
+ {
+ \hornNotes
+ }
+}
+@end lilypond
+
+You may even realize that this could be useful in minimalist music:
+
+@lilypond[quote,verbatim,ragged-right]
+fragmentA = \relative c'' { a4 a8. b16 }
+fragmentB = \relative c'' { a8. gis16 ees4 }
+
+violin = \new Staff {
+ \fragmentA \fragmentA |
+ \fragmentB \fragmentA |
+}
+
+\score {
+ {
+ \violin
+ }
+}
+@end lilypond
+
+However, you can also use these variables (also known as
+macros, or user-defined commands) for tweaks:
+
+@c TODO Avoid padtext - not needed with skylining
+@lilypond[quote,verbatim,ragged-right]
+dolce = \markup { \italic \bold dolce }
+
+padText = { \once \override TextScript #'padding = #5.0 }
+fthenp =_\markup {
+ \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p
+}
+
+violin = \relative c'' {
+ \repeat volta 2 {
+ c4._\dolce b8 a8 g a b |
+ \padText
+ c4.^"hi there!" d8 e' f g d |
+ c,4.\fthenp b8 c4 c-. |
+ }
+}
+
+\score {
+ {
+ \violin
+ }
+ \layout { ragged-right = ##t }
+}
+@end lilypond
+
+These variables are obviously useful for saving
+typing. But they're worth considering even if you
+only use them once -- they reduce complexity. Let's
+look at the previous example without any
+variables. It's a lot harder to read, especially
+the last line.
+
+@example
+violin = \relative c'' @{
+ \repeat volta 2 @{
+ c4._\markup @{ \italic \bold dolce @} b8 a8 g a b |
+ \once \override TextScript #'padding = #5.0
+ c4.^"hi there!" d8 e' f g d |
+ c,4.\markup @{
+ \dynamic f \italic \small @{ 2nd @} \hspace #0.1 \dynamic p
+ @}
+ b8 c4 c-. |
+ @}
+@}
+@end example
+
+@c TODO Replace the following with a better example -td
+@c Skylining handles this correctly without padText
+
+So far we've seen static substitution -- when LilyPond
+sees @code{\padText}, it replaces it with the stuff that
+we've defined it to be (ie the stuff to the right of
+@code{padtext=}).
+
+LilyPond can handle non-static substitution, too (you
+can think of these as functions).
+
+@lilypond[quote,verbatim,ragged-right]
+padText =
+#(define-music-function
+ (parser location padding)
+ (number?)
+ #{
+ \once \override TextScript #'padding = #padding
+ #})
+
+\relative c''' {
+ c4^"piu mosso" b a b |
+ \padText #1.8
+ c4^"piu mosso" d e f |
+ \padText #2.6
+ c4^"piu mosso" fis a g |
+}
+@end lilypond
+
+Using variables is also a good way to reduce work if the
+LilyPond input syntax changes (see
+@rprogram{Updating files with convert-ly}). If
+you have a single definition (such as @code{\dolce}) for all your
+input files (see @ref{Style sheets}), then if the syntax changes, you
+only need to update your single @code{\dolce} definition,
+instead of making changes throughout every @file{.ly} file.
+
+
+@node Scores and parts
+@subsection Scores and parts
+
+In orchestral music, all notes are printed twice. Once in a part for
+the musicians, and once in a full score for the conductor. Variables can
+be used to avoid double work. The music is entered once, and stored in
+a variable. The contents of that variable is then used to generate
+both the part and the full score.
+
+It is convenient to define the notes in a special file. For example,
+suppose that the file @file{horn-music.ly} contains the following part
+of a horn/@/bassoon duo
+
+@example
+hornNotes = \relative c @{
+ \time 2/4
+ r4 f8 a | cis4 f | e4 d |
+@}
+@end example
+
+@noindent
+Then, an individual part is made by putting the following in a file
+
+@example
+\include "horn-music.ly"
+
+\header @{
+ instrument = "Horn in F"
+@}
+
+@{
+ \transpose f c' \hornNotes
+@}
+@end example
+
+The line
+
+@example
+\include "horn-music.ly"
+@end example
+
+@noindent
+substitutes the contents of @file{horn-music.ly} at this position in
+the file, so @code{hornNotes} is defined afterwards. The command
+@code{\transpose f@tie{}c'} indicates that the argument, being
+@code{\hornNotes}, should be transposed by a fifth upwards. Sounding
+@code{f} is denoted by notated @code{c'}, which corresponds with the
+tuning of a normal French Horn in@tie{}F. The transposition can be seen
+in the following output
+
+@lilypond[quote,ragged-right]
+\transpose f c' \relative c {
+ \time 2/4
+ r4 f8 a | cis4 f | e4 d |
+}
+@end lilypond
+
+In ensemble pieces, one of the voices often does not play for many
+measures. This is denoted by a special rest, the multi-measure
+rest. It is entered with a capital @code{R} followed by a duration
+(@code{1}@tie{}for a whole note, @code{2}@tie{}for a half note,
+etc.). By multiplying the
+duration, longer rests can be constructed. For example, this rest
+takes 3@tie{}measures in 2/4 time
+
+@example
+R2*3
+@end example
+
+When printing the part, multi-rests
+must be condensed. This is done by setting a run-time variable
+
+@example
+\set Score.skipBars = ##t
+@end example
+
+@noindent
+This command sets the property @code{skipBars} in the
+@code{Score} context to true (@code{##t}). Prepending the rest and
+this option to the music above, leads to the following result
+
+@lilypond[quote,ragged-right]
+\transpose f c' \relative c {
+ \time 2/4
+ \set Score.skipBars = ##t
+ R2*3 |
+ r4 f8 a | cis4 f | e4 d |
+}
+@end lilypond
+
+
+The score is made by combining all of the music together. Assuming
+that the other voice is in @code{bassoonNotes} in the file
+@file{bassoon-music.ly}, a score is made with
+
+@example
+\include "bassoon-music.ly"
+\include "horn-music.ly"
+
+<<
+ \new Staff \hornNotes
+ \new Staff \bassoonNotes
+>>
+@end example
+
+@noindent
+leading to
+
+@lilypond[quote,ragged-right]
+\relative c <<
+ \new Staff {
+ \clef "treble"
+ \time 2/4
+ R2*3 |
+ r4 f8 a | cis4 f | e4 d |
+ }
+ \new Staff {
+ \clef "bass"
+ \time 2/4
+ r4 d,8 f | gis4 c | b4 bes |
+ a8 e f4 | g4 d | gis4 f |
+ }
+>>
+@end lilypond
+
+