<-- previous page Table of Contents Index next page -->
One possible use for defining one macro inside another is to make it act differently depending on how many times it has been called.
Suppose you want to have
pedal
on the first and third count of each
measure, but instead of having that printed for the whole song, you'd rather
just print pedal marks for a couple measures, and then say "simile."
However, for
MIDI,
you would want the pedal to apply to the entire song,
as well as both staffs, not just the one it is printed under.
One way to accomplish that is given below. A PED macro is defined.
Each time it is called, it defines another macro (ONCE, TWICE, and THRICE)
to keep track of how many times it has been called. On the third time,
it prints the "simile." In any case, if it is not doing MIDI and has not yet
reached THRICE, it prints the pedal marks. If it is doing MIDI,
it always applies pedal to both staffs.
score staffs=2 pedstyle=pedstar alignped=n staff 2 clef=bass define PED ifndef ONCE define ONCE \@ else ifndef TWICE define TWICE \@ else ifndef THRICE define THRICE \@ rom below 2: 1 "simile"; endif endif endif ifdef MIDI pedal below 1-2: 1;3; else ifndef THRICE pedal below 2: 1;3; endif endif @ music 1: c;e;f;a; 2: ceg;;cfa;; PED bar 1: e;g;f;a; 2: ceg;;cfa;; PED bar 1: c;e;f;a; 2: ceg;;cfa;; PED bar