This raises a further question which I can't see answered in the documentation: exactly what characters are allowed in a Lilypond variable name? NR says that the convention is alphabetic characters only, but you seem to have found that digits and full-stops are allowed. Is this documented, or did you experiment?
-------------------------
Monday, November 4, 2019, 6:46:05 PM, Timothy Lanfear wrote:
On 04/11/2019 09:28, Peter Toye wrote:
Re: Scoped variables
On further consideration I think that Timothy Lanfear has, probably inadvertently, made my point for me.
If a publisher wanted to collect Mr. Lanfear's string quartets (assuming that he has written more than one) into a single volume, the Lilypond code would have to be changed to rename all of the variables to something like QiIViolinI (using Roman numerals to keep to the published convention of alphabetic characters only - I'm surprised that Mr. Lanfear's version works at all). Using my idea, and assuming that the variables were defined within the score, noting has to change apart from the book and possibly bookpart sections. Much easier and less error-prone. Also, if each staff's content is in its own file in the same directory as its score, the same code will serve for all movements: \score {
\include "ViolinI.ly"
\include "ViolinII.ly"
\include "Viola.ly"
\include "Cello.ly"
}
Now you can have a directory/file structure like:
Book
Book.ly
Quartet1
Movement1
Score.ly
Violin1.ly
...
Movement2
Score.ly
etc.
I was surprised to find that provided there is no explicit \book statement, variables can be redefined between bookparts and behave as desired. \version "2.19.83"