lilypond-user
[Top][All Lists]
Advanced

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

Re: ignore code on include


From: Urs Liska
Subject: Re: ignore code on include
Date: Wed, 26 Apr 2017 18:44:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0


Am 26.04.2017 um 18:36 schrieb Noeck:
> Hi,
>
> in python you can add code under this condition:
> if __name__ == "__main__"
> This way it is only executed if this file is the main file that is
> executed. If the file is only imported ("included"), this code is skipped.
>
> There is nothing similar in LilyPond, is there?
>
> I am asking because it would be handy to have a file soprano.ly with the
> soprano notes which can be included to use them. And if it is run on its
> own, it produces a score containing only the soprano voice.
>
> I know that I can do that with multiple files. But I would be interested
> if that exists.

Maybe
https://github.com/openlilylib/oll-core/blob/master/package.ily
or
https://git.openlilylib.org/bfsc/das-trunkne-lied/blob/master/library/ly/makescore/compile-segment.ily
give you some inspiration?

The latter is probably your use-case: using a file either as an included
or a standalone one. The idea is to define a function whose
implementation is different depending on the presence of a flag. At the
end of the file the function is called and does the appropriate thing.

HTH
Urs

> Cheers,
> Joram
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user

-- 
address@hidden
https://openlilylib.org
http://lilypondblog.org




reply via email to

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