On Fri, 2023-12-15 at 22:04 +0100, Andreas Schneider wrote: > On 15.12.23 21:33, Richard Shann wrote: > > On Fri, 2023-12-15 at 19:48 +0100, Andreas Schneider wrote: > > > I'm trying to write a Scheme script for an incipit > > > ( > > > https://lilypond.org/doc/v2.23/Documentation/notation/working-with-anc > > > ient-music-_002d-scenarios-and-solutions#incipits). > > > I have started from the script for instrument name and modified > > > it to > > > match my needs arriving at the following: > > > > > > ;;;Incipit > > > (let ((tag "Incipit") (current "") ) > > > (if (string? Incipit::params) > > > (begin > > > (set! current Incipit::params) > > > (set! Incipit::params #f))) > > > (set! current (d-GetUserInput (_ "Incipit") (_ "Give incipit for > > > current > > > staff:") current)) > > > (if (string? current) > > > (begin > > > (d-DirectivePut-staff-prefix tag (string-append "incipit { " > > > current > > > " }") > > > (set! Incipit::params current))))) > > > > > > Unfortunately, I get a script error > > > > the error message ends: > > > > (#f Unbound variable: ~S (Incipit::params) #f) > > Denemo - WARNING : > > The tag is > > > > unbound-variable > > > > Which is telling you that Incipit::params in an unbound-variable. > > This > > variable would be created if you invoked this script via a command > > called Incipt - that is each command in the menu creates a variable > > named xxxx::params when it is invoked (setting it to #f if its > > invoked > > from a menu). > > Thanks for your quick response. So I need to make a menu item out of > it > in order to test it.
well you could execute (define Incipit::params #f) before trying to execute your script. > I did that and now I proceed a little bit further > and can enter some incipit (e.g. \clef "mensural-c2" \time 3/2 d' 2 > c' 1 > d' 2 e' d' e'), but finally I get the error > > (#f Wrong number of arguments to ~A (#<procedure > d-DirectivePut-staff-prefix (_ _)>) #f) > wrong-number-of-args so it is saying you have the wrong number of arguments to the procedure d-DirectivePut-staff-prefix which needs two: a tag (a unique name for the directive) and a string (some LilyPond syntax to insert "before" the staff). > > What do I do different than in InstrumentName? you have misplaced the closing parenthesis for the (d-DirectivePut- staff-prefix tag arg) procedure. If you step the cursor back from the end of the script you can see the matching opening parentheses for each ")" and you will see that the (d-DirectivePut-staff-prefix is followed by tag, (string-append ...) and (set! ...). This last one should be the second argument to the (begin ...) not a third argument to the (d- DirectivePut-staff-prefix ...). So you need to add a ")" after the (string-append ...) and remove it from the end of the script. Having said that, I can see other problems looming - the syntax you are emitting starts "incipit " whereas according to the docs it should be "\incipit" which in Scheme is written £\\incipt£ (because you want a literal "\" character). And then it will need some work to emit the syntax at the right place - InstrumentName puts it in a \with {} clause by setting a (d-irectivePut-staff-override tag ...). I'll take a look later at what override you need if any (there is a denemo score shipped with denemo that illustrates the various overrides available). Richard > > Andreas >