lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme help request: How can else of an if-statement be made to do n


From: Matthew Fong
Subject: Re: Scheme help request: How can else of an if-statement be made to do nothing?
Date: Sat, 17 Oct 2020 11:23:28 -0700

Hello Jean and Thomas,

Thank you -- both solutions are insightful and useful in future solutions.

I did not know about empty stencils, and I read about a void-function earlier, but was not entirely sure how to utilize it.


Many thanks,
mattfong

On Sat, Oct 17, 2020 at 10:49 AM Thomas Morley <thomasmorley65@gmail.com> wrote:
Am Sa., 17. Okt. 2020 um 19:39 Uhr schrieb Jean Abou Samra <jean@abou-samra.fr>:
>
> Hi,
>
> Le 17/10/2020 à 19:27, Matthew Fong a écrit :
>
> > Hello Richard,
> >
> > I just discovered your explanation is in fact the case, and also
> > concluded cond wouldn't work either.
> >
> > I might have to settle for an empty markup block for now.
>
> The point of interpret-markup is to turn a markup into a stencil, so I'd
> use empty-stencil:
>
> \version "2.20.0"
>
> #(define-markup-command (print-if-defined layout props sym text)
>                          (symbol? markup?)
>    (if (defined? sym)
>        (interpret-markup layout props
>          #{ \markup \with-color #'(0.8 0.2 0.2) #text #})
>        empty-stencil))
>
> symA = "Something"
>
> \markup {
>    \print-if-defined #'symA "Text"
>    \print-if-defined #'symB "More text"
> }
>
> Best,
> Jean
>
>

An empty stencil will still be spaced (unless removed by other markup-commands).
Why not a void-function?

print-if-defined =
#(define-void-function (sym text) (symbol? markup?)
  (if (defined? sym)
      (add-text #{ \markup \with-color #'(0.8 0.2 0.2) #text #})))

symA = "Something"

\print-if-defined #'symB "Text"
\print-if-defined #'symA "Text"

Cheers,
  Harm

reply via email to

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