Hi,

I'm once more struggling with the commands to include files within
Scheme functions.

In the attached .ily files one defines a music expression while the
other uses it in a Staff definition.

I can happily make that work using regular \includes or by calling
ly:parser-include-string twice. But I need to wrap this into a Scheme
function to include multiple files from within a function and process
the results (the music expressions from the files) within the same function.

I am not surprised that the second approach (using
ly:parser-include-string twice within the function) doesn't work. Last
time this question popped up I learned that any definition from inside
the included file will only be visible after the function has returned.
(uncomment second example to see it "in action").

So I thought I had to use ly:parser-parse-string together with
ly:parser-clone to make the definitions available earlier, and in
another context this worked
(https://github.com/openlilylib/oll-core/blob/master/oll-core.ily#L59).

However, this time I get strange errors with the parse-string function
as that doesn't even seem to be able to parse the first file properly.
The first error is

levelOne.ily:3:19 <0>: error: wrong type for argument 2. Expecting
music, found "c"

music = \relative

c' { c }

followed by numerous consecutive errors that are probably neglectable.

I would very much appreciate any further clarification and assistance as
I really don't have a clue how to proceed.

Urs

PS: The actual context is
https://git.openlilylib.org/bfsc/kayser/blob/score/includes/lib/file-handling.ily#L124
(the unfinished stuff starting from L. 143), but I'm not sure if that's
sufficiently retraceable from that page)

\version "2.19.43"

% Including them one after another works fine
%%{

#(ly:parser-include-string "\\include \"levelOne.ily\"")
#(ly:parser-include-string "\\include \"levelTwo.ily\"")

%}

% Wrapping the includes in a Scheme function doesn't work
% because \music will only be visible when the expression
% has been fully evaluated (i.e. after leaving the function).
%{

includeBoth =
#(define-void-function ()()
   (ly:parser-include-string "\\include \"levelOne.ily\"")
   (ly:parser-include-string "\\include \"levelTwo.ily\""))

\includeBoth

%}


% Using ly:parser-parse-string with a parser clone doesn't
% work either because it seems not to be able to parse
% the (first) file in the first place.
%{

includeBoth =
#(define-void-function ()()
   (ly:parser-parse-string (ly:parser-clone)
     "\\include \"levelOne.ily\"")
   (ly:parser-parse-string (ly:parser-clone)
     "\\include \"levelTwo.ily\""))

\includeBoth

%}

\version "2.19.43"

music = \relative c' { c }
\version "2.19.43"

\new Staff \music
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to