lilypond-user
[Top][All Lists]
Advanced

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

Re: Include a file if it exists


From: Urs Liska
Subject: Re: Include a file if it exists
Date: Tue, 09 Sep 2014 02:31:05 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Hello Gilles,

thank you very much.
Your solutions do work, but I don't think I'll use them in my project.

But you have unintentionally pushed me in the right direction (with the "emptyfile.ly" thing).
What I'll do now is:

- create empty replacement files 01.ily through 90.ily in an arbitrary folder
- add this folder to LilyPond's include path
- simply use \include "19.ily"

When that file isn't present in the current folder Lily will simply use the replacement one :-)

Thanks again

Best
Urs

Am 08.09.2014 23:14, schrieb Gilles THIBAULT:
I found out that using
#(ly:parser-parse-string (ly:parser-clone parser) "\\include \"01.ily\"")
_does_ actually work, but not when the included file contains variable
definitions (e.g. "music = ...").
Still no ideas?

Perhaps something like that :


%%%%%%%%%%

\version "2.18.2"

file = #(let((myfile "test.ly"))
(if (file-exists? myfile)
        myfile
        "emptyfile.ly"))

\include #file

%%%%%%%%%

which seems to works, but you need to create an empty file "emptyfile.ly"
somewhere in your PATH.
Alternatively, this seems also to work :

...
(if (file-exists? myfile)
        myfile
        ""))

but you will get an advertisement for the \include ""






reply via email to

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