Am 05.07.2016 um 15:27 schrieb David Kastrup: > Urs Liska <[email protected]> writes: > >> 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"). > Perhaps you should unlearn that. It's nonsensical. The problem rather > is that ly:parser-include-string pushes a string on the input stack, so > your includes are processed in reversed order. > > Why would you even do multiple ly:parser-include-string calls in one > function instead of building _one_ string and including that? >
Well, first of all I wouldn't have thought of it, so I felt very embarrassed at first. But actually the problem is that my function is kind of an adaptor. It includes a number of files (i.e. all from a directory that match a pattern), and each file defines the same variables (e.g. \music, \lyricText and \bcFigures). The function wants then to either rename them so they can independently be used in a score or rather store them in a tree where the function building the score will later fetch them from. So, within my function I have to iterate over the list of files, include them and process the variables that are defined within the files. _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
