Hi Joram,

I use a scheme-function for that purpose. Here is a cutdown, that shows the essential test.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(use-modules (ice-9 regex))

#(define-public (test-location? parser location)
  (let ((outname (ly:parser-output-name parser))
        (locname (car (ly:input-file-line-char-column location))))
(regexp-match? (string-match (format "^(.*/)?~A\\.i?ly$" outname) locname))
    ))

#(if (test-location? (*parser*) (*location*)) (display "Yes"))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

HTH
Jan-Peter

Am 26.04.2017 um 18:36 schrieb Noeck:
Hi,

in python you can add code under this condition:
if __name__ == "__main__"
This way it is only executed if this file is the main file that is
executed. If the file is only imported ("included"), this code is skipped.

There is nothing similar in LilyPond, is there?

I am asking because it would be handy to have a file soprano.ly with the
soprano notes which can be included to use them. And if it is run on its
own, it produces a score containing only the soprano voice.

I know that I can do that with multiple files. But I would be interested
if that exists.

Cheers,
Joram

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user



_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to