[Repost: The first post Thunderbird had HTML 'on'. The appended short example was a mess. My apologies.]

First time post

Attached is a short, I dare not call it tiny, lilypond input file demonstrating an issue with (file-exists? and the use of --include=DIRECTORY on the command line.

Is there a list or string that I can access from a lilypond script that contains the entire search path? In the application here, the path has to contain additions from -include=DIRECTORY.

To run example shown below, a separate directory 'RealBookClone' and 'LilyJAZZ.ily' as a dummy file in 'RealBookClone' are needed.
--
Regards,
Rob D.
===============No HTML, example of command line and output ==
E6410% lilypond --include=RealBookClone fileExistExample.ly
GNU LilyPond 2.25.19 (running Guile 3.0)
Processing `fileExistExample.ly'
Parsing...
file-exists #f "LilyJAZZ.ily"
file-exists #t "RealBookClone/LilyJAZZ.ily"
Reading LilyJAZZ.ily
Success: compilation successfully completed
\version "2.25.19"
%
% The void-function below will include file named in string 'file'
% using the (parser-include-string ...).
% 
% But only if the named file is present as tested by (file-exists? file)
%
%
% E6410% lilypond --include=RealBookClone fileExistExample.ly
% The issue is the use of --include= directives on the command line.
% When the search path is exapanded on the command line
% (file-exists? file) does not appear to traverse the expanded include path.
%
% Adding a loop over the path to the void-function includeIfExists (below) 
% would allow (file-exist? file) be placed within that loop.
% 
includeIfExists =
#(define-void-function (file)(string?)
    (if (file-exists? file)
        (begin 
           (ly:message (ly:format "file-exists #t \"~A\"\n" file))
           (ly:parser-include-string (ly:format "\\include \"~A\"\n" file)))
        (ly:message (ly:format "file-exists #f \"~A\"\n" file))))
          
%
% Assume the file "LilyJAZZ.ily" may or may not exist in a 
% separate directory % defined by --include=RealBookClone 
%
\includeIfExists "LilyJAZZ.ily"

%
% It is possible to hardcode the path in the lilypond source 
% but that makes the idea of adding to a search path from the 
% command line superfluous.
%
\includeIfExists "RealBookClone/LilyJAZZ.ily"

%
% Uncomment the line below to demonstrate parser-include-string 
% can find a file in --include search path
% 
%#(ly:parser-include-string (ly:format "\\include \"~A\"\n" "LilyJAZZ.ily"))

%
% Uncomment the line below to demonstrate 
% parser-include-string the error the new function
% (void-function includeIfExists seeks to avoid
%
%#(ly:parser-include-string (ly:format "\\include \"~A\"\n" "NonexistantFile.ily"))

Reply via email to