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: Gilles THIBAULT
Subject: Re: Include a file if it exists
Date: Mon, 08 Sep 2014 23:14:34 +0200
User-agent: KMail/4.11.4 (Linux/3.12.25-desktop-3.mga4; KDE/4.11.4; x86_64; ; )

> 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 ""


-- 
Gilles



reply via email to

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