Implementing a counter in markup text: Difference between revisions
mNo edit summary |
Rudi Guggt (talk | contribs) warning in red |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
This snippet shows how to implement a counter in LilyPond for use in markup texts. Whenever you call the <code>\counter "name"</code> markup function, the counter named <code>name</code> will be increased by one and the new value will be printed as a text markup. The first call will print “1” by default. Example: | This snippet shows how to implement a counter in LilyPond for use in markup texts. Whenever you call the <code>\counter #"name"</code> markup function, the counter named <code>name</code> will be increased by one and the new value will be printed as a text markup. The first call will print “1” by default. Example: | ||
\markup { | \markup { | ||
| Line 38: | Line 38: | ||
\markup { Set first counter to 15: \setcounter #"mycounter" #15 } | \markup { Set first counter to 15: \setcounter #"mycounter" #15 } | ||
\markup { It is increasing: \counter #"mycounter" } | \markup { It is increasing: \counter #"mycounter" } | ||
\markup { | \markup \with-color #red { Don't rush it: } | ||
\markup { Three calls in a row: \counter #"mycounter", \counter #"mycounter" and \counter #"mycounter" } | \markup { Three calls in a row: \counter #"mycounter", \counter #"mycounter" and \counter #"mycounter" } | ||
\markup { It is increasing: \counter #"mycounter" } | \markup { It is increasing: \counter #"mycounter" } | ||