lilypond-user
[Top][All Lists]
Advanced

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

Re: Variables and Bookpart


From: Saul Tobin
Subject: Re: Variables and Bookpart
Date: Sun, 12 Mar 2023 16:34:33 -0700

A slightly nicer syntax to workaround this limitation is to use the function:

parserDefine =
#(define-void-function (name val)(symbol? scheme?)
    (ly:parser-define! name val))

Then instead of var = { ... } you can write \parserDefine var { ... }.

I believe this was posted on the list a few years ago.

On Sun, Mar 12, 2023 at 4:26 PM Valentin Petzel <valentin@petzel.at> wrote:
If I’m thinking correctly what Mark attempts to do is to have multiple files
containing scores and then to

\bookpart {
  \include ...
}

to combine these scores. The problem here is quite simple: The notation

name = value

is something that is evalutated by the parser and will generally evaluate
differently depending on which context this is used in. Only on top level this
will be valuated to "define a music macro". In the context of an output def
such as \paper of \layout and in \header this is interpreted as "set this
particular property". In other cases this will only be allowed in conjuction
with the reserved keywords \override and \set.

Anyway the point is that the parser will not allow you to do this kind of
syntax if you are not at toplevel.

But that does not mean you cannot set such values, it just means you cannot
use this syntax for it. By directly setting the scheme binding we can still do
this:

\bookpart {
  #(define ArightOne #{ \relative c'' { c b a b } #})
  \score { \ArightOne }
}

(by the way this also allows us to define bindings the parser does not handle
well such as e.g. \c: c = ... will not be allowed, as c is a note name, but
#(define c ...) works).

Cheers,
Valentin

Am Sonntag, 12. März 2023, 23:51:28 CET schrieb Hans Aikema:
> > On 12 Mar 2023, at 20:38, Mark Stephen Mrotek <carsonmark@ca.rr.com>
> > wrote:
> >
> > Jean Abou Samra,
> >
> > Thank you.
> > Yes variables must (and are) placed before the \score in each individual
> > movement. That is why each complies perfectly when done individually. The
> > error appears when the code for the movement (that compiles) is copied
> > and pasted into the \bookpart.
> >
> > Your kind attention is appreciated.’
> >
> > Mark
>
> […]
>
> Mark,
>
> Based on your response I think you did not get the nuances of what Jean
> tried to tell you.
>
> The copying/pasting of your working score INSIDE \bookpart means that you
> are copying your variable definition (which is already properly outside the
> \score) INSIDE the \bookpart, while it should be outside both the \bookpart
> and the \score
>
> So you should
>
> {copy variables to here}
> \bookpart {
>       {copy rest of the score here}
> }
>
> When using copy/paste of your score into a file with a \bookpart
>
>
> HTH
> Hans


reply via email to

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