GnuCash reports via eguile - probably not

Chris Dennis cgdennis at btinternet.com
Mon Jan 26 20:18:48 EST 2009


Derek Atkins wrote:
> Quoting Derek Atkins <warlord at MIT.EDU>:
> [snip]
>>> Can any Guile/Scheme experts help?
> 
> I found some help, and here's some working code:
> 
> ;#! /usr/bin/guile
> (define fred "This is Fred")
> 
> (define (foo bar)
>   (display fred) (newline) (display bar) (newline)
>   (display "and now via eval-string...") (newline)
>   (let ((string1 "(begin (display bar) (newline) (display fred) (newline)
> (display bar) (newline))"))
>     (with-input-from-string string1 (lambda () (local-eval (read)
> (the-environment))))
>     ))
> (foo "Actual parameter")
> 
> 
> Note that I added the 'begin' because the 'read' will only read in one
> s-expression.  You could theoretically read in multiple s-expressions
> in a loop if you wanted.  But this was easier.
> 
> This code works for me.
> 
> -derek
> 
> 

I'm making progress with this, but I've hit another snag with 
local-eval.  The following code gives an error (note the extra "(define 
x 42)":

------
;#! /usr/bin/guile
(define fred "This is Fred")
(define (foo bar)
   (let ((string1 "(begin (display fred) (newline) (display bar) \
           (newline) (define x 42) (display x) (newline))"))
     (with-input-from-string string1 (lambda () (local-eval (read) 
(the-environment))))))
(foo "Actual parameter")
------
gives
------
ERROR: Bad define placement
------

I found a mention of this issue at 
http://www.opensubscriber.com/message/guile-user@gnu.org/9617568.html
but I'm not sure whether to give up on local-eval, or just make a rule 
that the template code can't include 'define', which would be a bit 
limiting.

Any ideas?

cheers

Chris
-- 
Chris Dennis                                  cgdennis at btinternet.com
Fordingbridge, Hampshire, UK


More information about the gnucash-devel mailing list