Re: [frogs] Re: Naming output files

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]



2009/2/26 Reinhold Kainhofer <reinhold@xxxxxxxxxxxxx>

On Donnerstag, 26. Februar 2009 22:38:53 Marek Klein wrote:
>        (output-count (assoc-ref counter-alist 'output-suffix))
>        (base (ly:parser-output-name parser))
>        (output-suffix (ly:parser-lookup parser 'output-suffix)) )

You need to reverse this! The key for the assoc-ref lookup should NOT be the
'output-suffix symbol (note the '), but rather the value output-suffix, which
you look up only later. So, simply move the definition of output-count after
the output-suffix and use output-suffix instead of 'output-suffix.

Later on, you use output-suffix in assoc-set!, so you need to use the same
value in the assoc-ref, too.

Cheers,
Reinhold

Thank you,
now it works as expected:

(define counter-alist '())

(define (print-book-with parser book process-procedure)
  (let*
      ((paper (ly:parser-lookup parser '$defaultpaper))
       (layout (ly:parser-lookup parser '$defaultlayout))
       (output-suffix (ly:parser-lookup parser 'output-suffix))
       (output-count (assoc-ref counter-alist output-suffix))
       (base (ly:parser-output-name parser)) )
     
      (if (string? output-suffix)
    (set! base (format "~a-~a" base (string-regexp-substitute
                       "[^a-zA-Z0-9-]" "_" output-suffix))))

    ;; must be careful: output-count is under user control.
    (if (not (integer? output-count))
    (set! output-count 0))

    (if (> output-count 0)
    (set! base (format #f "~a-~a" base output-count)))
    (set! counter-alist (assoc-set! counter-alist output-suffix (1+ output-count)))

What about set! versus ly:parser-define! ?

--
Marek Klein
http://gregoriana.sk


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/