lilypond-user
[Top][All Lists]
Advanced

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

Re: \include inside function


From: Valentin Petzel
Subject: Re: \include inside function
Date: Tue, 01 Feb 2022 19:33:29 +0100

Hi David!

I suppose it might be useful to have something like a parsing function that 
does parse a file internally, but returns a scheme structure containing all 
variables, functions, scores, books, whatever defined in that file. This would 
make using stuff in a different file much more clean than the current include 
method.

Cheers,
Valentin

Am Dienstag, 1. Februar 2022, 17:33:13 CET schrieb David Kastrup:
> Leo Correia de Verdier <leo.correia.de.verdier@gmail.com> writes:
> > Dear list!
> > 
> > Is there a way to have an \include inside a function?
> > In the attached file includeinfunction.ly the commented out line
> > doesn’t work (probably for some very logical reason, but still unknown
> > to me).
> 
> Uh, if you write the content of the included file _exactly_ where
> \include #filename now is, you get _exactly_ the same error.  Your
> inclusion works perfectly fine.  It's just that the syntax in the file
> is not valid syntax inside of #{ ... #}.
> 
> If you want to include the file instead at the _top_ level, try
> 
> includeFunction = #(define-void-function (filename) (string?)
>                      (ly:parser-include-string (format "\\include ~s"
> filename)))
> 
> However, depending on the context you use this in, you might get
> surprised by just _when_ the inclusion happens.
> 
> > Is there a way to work around that and have includes inside functions?
> > 
> > (The function in this case is indeed meaningless, in my real use case
> > the function will hopefully construct midi files from the variables in
> > the included files combined in different ways)
> > 
> > Thanks a lot!
> > 
> > /Leo
> > 
> > \version "2.23.3"
> > 
> > includeFunction = #(define-void-function (filename) (string?)
> > 
> >                      #{ \include #filename #} )
> > 
> > \include "includetest.ily"
> > 
> > % \includeFunction "includetest.ily"
> > 
> > \score { \music }

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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