denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] Scheme script debugging


From: Richard Shann
Subject: Re: [Denemo-devel] Scheme script debugging
Date: Wed, 22 May 2013 10:05:32 +0100

On Wed, 2013-05-22 at 08:18 +0200, Andreas Schneider wrote:
> Am 21.05.2013 23:26, schrieb Richard Shann:
> > I'll look tomorrow, but this message means there are unbalanced () I
> > think. I really don't recognize the (let xxx () syntax you are using,
> > xxx is a procedure being defined by this construct IIRC, used for
> > looping (called "named let" IIRC).
> 
> I am more or less guessing, using existing scripts as templates and
> doing things similar, as (up to my knowledge) there is no documentation
> of the script language.

Denemo's script language is a superset of scheme, that is, it is scheme
plus a bunch of procedures such as d-DirectiveGet-movementcontrol-prefix
and so on.
So when I referred to (let xxx () syntax, I just mean the scheme syntax
for the "let" procedure.
Scheme is well documented, with the official reference here:

http://www.gnu.org/software/guile/manual/html_node/index.html

Named "let" is documented at
http://www.gnu.org/software/guile/manual/html_node/while-do.html#while-do

while the way "let" makes variables local to the let is documented at
http://www.gnu.org/software/guile/manual/html_node/Local-Bindings.html#Local-Bindings


Guile is the interpreter for scheme, and Denemo provides a CLI at the
top of the scheme window.
So if you want to check if a procedure name is correct you can type it
in there and hit return and the output (in the console) will tell you
what it is.

But, yes we could do with documentation on the Denemo procedures: there
is ancient documentation on the Denemo directive fields in the manual,
but things have moved on since then, and there are various easier-to-use
procedures, for which I have to look in an existing script and/or look
in the sources $PREFIX/actions/denemo-modules/*.scm to see if what I
want is already defined (Nils wrote most of this stuff I think).

In your code I have changed the ((let to (set!, dropped the (disp ...)
calls and balanced the closing parentheses and I get this:

;;;MarkupAtEnd
(let ((tag "MarkupAtEnd")(themarkup #f))
        (d-DirectivePut-movementcontrol-override tag DENEMO_OVERRIDE_GRAPHIC)
        (d-DirectivePut-movementcontrol-display tag "MarkupAtEnd")
        (disp "checking previous markup ...")
        (if (d-Directive-movementcontrol? tag)
                (set! themarkup (d-DirectiveGet-movementcontrol-postfix tag))
              
                (set! themarkup (""))
             
        )
        (set! themarkup (d-GetUserInput (_ "MarkupAtEnd") (_ "Edit markup:")
themarkup))
        (disp themarkup)
        (d-DirectivePut-movementcontrol-postfix tag themarkup)
        (d-DirectivePut-movementcontrol-override tag DENEMO_OVERRIDE_AFFIX)
        (d-SetSaved #f)


which does execute. The (disp xxx) procedures can't just be added in to
the (if  xxx yyy) because "if" takes one or two arguments, so just
putting in extra (disp zzz) gives too many arguments.
Instead you need this


(if a
        (begin
                (something for the if case)
                (disp "a is true"))
        (begin
                (something for the else case)
                (disp "a is #f)))

where the "if" has two arguments (begin ...) and (begin ...)
The "begin" procedure just groups expressions together to make a single
expression, so that the "if" gets two arguments.

But, as I say, this is scheme syntax, which, while there is not a lot of
it, does need reading up first.

I hope you didn't feel I was being critical of your effort - I'm pleased
to see you giving a try at writing a script.

Your script is placing markup at the end of the \score { ......} block
before the closing }, which I don't think is allowed LilyPond syntax.
To get the movementcontrol directive to put the postfix in the right
place may require some adjustment to the override field. If you let me
know what output LilyPond you are trying for I'm sure it can be done...

HTH

Richard







reply via email to

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