Eguile report templates -- another hurdle - SOLVED!
Chris Dennis
cgdennis at btinternet.com
Sun Feb 1 19:44:48 EST 2009
Andrew Sackville-West wrote:
> On Sun, Feb 01, 2009 at 12:23:14PM +0000, Chris Dennis wrote:
>> Chris Dennis wrote:
>>> Hello folks
>>>
>>> My project bring HTML templates to GnuCash reports is making good progress.
>>>
>>> But I've stumbled on another problem which requires expert knowledge of
>>> GnuCash and/org Swig and/or Guile.
>>>
>>> My evaluated report code can access some Gnucash procedures such as
>>> gnc:make-html-text, but others such as gncInvoiceGetBook remain 'unbound'.
>> In fact the error message refers to 'gncinvoicegetbook' as being
>> unbound, i.e. with the name in lower case. Is that relevant? Guile is
>> supposed to be case-sensitive unless you tell it not to be.
>>
>> I can reproduce the problem with this bit of code:
>>
>> 8<--------------
>> ;#!/usr/bin/guile
>> (define s1 "(abcDEF \"23\")")
>> (define (abcDEF x)
>> (display (string-append "This is abcDEF called with " x "\n")))
>> (with-input-from-string s1 (lambda () (local-eval (read)
>> (the-environment))))
>> (read-enable 'case-insensitive)
>> (with-input-from-string s1 (lambda () (local-eval (read)
>> (the-environment))))
>> 8<--------------
>>
>> After setting read to be case insensitive, local-eval tries to call
>> (abcdef) and can't find it.
>>
>> I can't find anywhere in the GnuCash code that turns on case-insensitivity.
>>
>> Does anyone have any idea why this would happen?
>
> not a clue, but have you tried
>
> (read-disable 'case-insensitive)
>
> in your code somewhere to confirm that this is the problem?
>
> A
Thanks for the suggestion. I tried putting (read-disable
'case-insensitive) in all sorts of places in the code and none of them
made any difference. Adding (read-options) in various places confirmed
that 'case-insensitive had NOT been set.
So I tried all sorts of things to reproduce the error, and eventually
(with much wailing and gnashing of teeth), realised that the culprit was
(use-modules (ice-9 slib))
which I must have copied from another report, and wasn't actually needed
anyway.
http://www.gnu.org/software/guile/manual/html_node/SLIB.html says "In
general (and as might be expected) when SLIB is loaded it's the SLIB
specifications that are followed." Which apparently includes
case-insensitivity!
So let that stand as a lesson to young programmers: Guile is
case-sensitive and Scheme isn't. Using slib puts Guile into Scheme-like
mode for all future (read)s.
And now I can finally make more progress with my wonderful report
templating system. Tomorrow.
cheers
Chris
--
Chris Dennis cgdennis at btinternet.com
Fordingbridge, Hampshire, UK
More information about the gnucash-devel
mailing list