lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to include a file just once?


From: James Bailey
Subject: Re: How to include a file just once?
Date: Thu, 21 Jan 2010 20:55:23 +0100


On 21.01.2010, at 18:47, Michael J. O'Donnell wrote:

Is there a standard way to make sure that a file full of LilyPond style definitions is included just once, no matter how many times it is mentioned?

I searched the Web site, mail archives, and /usr/shar/lilypond for
"include once" and "include guard", to no avail. With the C
preprocessor, there is a standard trick for setting and testing a
variable to disable all but the first attempt to include a header file.
Some languages have an "include-once" command.

I am putting together a large choral score from bookparts for each
number in the work. I like to be able to produce either a single number, or the whole score. The natural approach is to include style definitions in each of the files that I might set, including the file to format the whole score and the files to format individual numbers. Files to format
individual numbers also include the style definitions.

I find that repeated inclusion of the same definitions leads quickly to
a segmentation fault.

I can either add one more level of indirection, with one more file per
number. Or, I can do some Scheme hacking, with a global variable to set
showing inclusion (tricky, because the variable needs to be testable
reliably even when it has never been set explicitly).

But, I'd prefer to use a well-known standard method, if it exists.

Thanks,

Mike O'Donnell


One solution might be to have either notes or layout definitions in a file, but not both. It quickly leads to large amounts of files, but you can have separate book files which create the actual parts, and not have multiple includes.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]