Subject: include if exist

From: Sebastien Richard <[email-masked]>
Date: Tue, 7 Mar 2023 20:00:22 +0000

Bonsoir à tous,

J'ai récemment mis à jour mon PC (linux mint 18.3 vers 20.3) ce qui a eu pour effet de changer la version de lilypond que j'utilisais.

J'utlisais autrefois ce bout de code qui me permettait d'inclure un fichier seulement s'il existait:

\version "2.18.2"

includeIfExists =
#(define-music-function (parser location file)(string?)
   (if (file-exists? file)
       (ly:parser-include-string parser (format "\\include \"~A\"\n" file)))
   (make-music 'SequentialMusic 'void #t))

\includeIfExists "/home/oneusername/lilypond/mydrums.ly"
\includeIfExists "/home/anotherusername/Drum/Lilypond/mydrums.ly"

La version de Lilypond que j'ai à présent est 2.20.0 et cette function ne "fonctionne" plus:

Parsing.../home/seb/Documents/Drum/Lilypond/Bonham/Bonham (copy).ly:6:8: In procedure ly:parser-include-string in expression (ly:parser-include-string parser (format "\\include \"~A\"
" file)):
/home/seb/Documents/Drum/Lilypond/Bonham/Bonham (copy).ly:6:8: Wrong number of arguments to #<primitive-procedure ly:parser-include-string>

Je n'ai absolument aucune idée de comment corriger cette fonction. Quelqu'un pourrait il m'aider ?

Merci

------
 Filo

---

From: Ben <[email-masked]>
Date: Wed, 8 Mar 2023 09:02:56 +0100

Bonjour Filo, 

Chez moi, cela fonctionne:

\version "2.18.2"

includeIfExists =
#(define-void-function (parser location file)(string?)
   (if (file-exists? file)
       (ly:parser-include-string (format #f "\\include \"~A\"\n" file)))
   )

\includeIfExists "/home/oneusername/lilypond/mydrums.ly <http://mydrums.ly/>"

Au plaisir, 

Ben

> Le 7 mars 2023 à 21:00, Sebastien Richard <[email-masked]> a écrit :
> 
> Bonsoir à tous,
> 
> \includeIfExists "/home/oneusername/lilypond/mydrums.ly <http://mydrums.ly/>"
> \includeIfExists "/home/anotherusername/Drum/Lilypond/mydrums.ly <http://mydrums.ly/>"
>

---

From: Sebastien Richard <[email-masked]>
Date: Wed, 8 Mar 2023 15:42:58 +0000

Bonjour Ben

Exact çà fonctionne à présent

Un grand merci à toi

Cdt,

------
 Filo

________________________________
From: Ben <[email-masked]>
Sent: Wednesday, March 8, 2023 09:02
To: Sebastien Richard <[email-masked]>
Cc: [email-masked] <[email-masked]>
Subject: Re: include if exist

Bonjour Filo,

\version "2.18.2"

includeIfExists =

\includeIfExists "/home/oneusername/lilypond/mydrums.ly<http://mydrums.ly/>"

Au plaisir,

Ben

Le 7 mars 2023 à 21:00, Sebastien Richard <[email-masked]<mailto:[email-masked]>> a écrit :

Bonsoir à tous,

\version "2.18.2"

includeIfExists =

\includeIfExists "/home/oneusername/lilypond/mydrums.ly<http://mydrums.ly/>"
\includeIfExists "/home/anotherusername/Drum/Lilypond/mydrums.ly<http://mydrums.ly/>"

Merci

------
 Filo