[GNC-dev] [GNC] Dipping my toes into Scheme

Christopher Lam christopher.lck at gmail.com
Mon Mar 23 08:48:45 EDT 2020

This is more suitable for devel.

On Mon, 23 Mar 2020 at 11:29, Michael Hendry <hendry.michael at gmail.com>

> Rather than dive into Scheme programming with a completely new report, I’d
> like to try editing an existing report to provide a little customisation.
> I’m looking at the experimental report balsheet-pnl.scm by Christopher
> Lam, which I found here on my Mac…

Not the easiest report to start with.

> In other programming environments I would simply save the edited file and
> run it, but I can see a few pitfalls!
> Line 28 reads:
> (define-module (gnucash report standard-reports balsheet-pnl))
> which should presumably be changed, e.g. to:
> (define-module (gnucash report standard-reports MH_balsheet-pnl))

Correct. The define-module name must match the file path; this is a
requirement in the standard-reports folder. Can't remember where exactly
this is enforced.

After that, I think it should be plain sailing until line 1340:
> (define balsheet-reportname (_ "Balance Sheet (Multicolumn)"))
> (define pnl-reportname (_ "Income Statement (Multicolumn)"))
> (gnc:define-report
>  'version 1
>  'name balsheet-reportname
>  'report-guid "065d5d5a77ba11e8b31e83ada73c5eea"
>  'menu-path (list gnc:menuname-experimental)
>  'options-generator (lambda () (multicol-report-options-generator
> 'balsheet))
>  'renderer (lambda (rpt) (multicol-report-renderer rpt 'balsheet)))
> (gnc:define-report
>  'version 1
>  'name pnl-reportname
>  'report-guid "0e94fd0277ba11e8825d43e27232c9d4"
>  'menu-path (list gnc:menuname-experimental)
>  'options-generator (lambda () (multicol-report-options-generator 'pnl))
>  'renderer (lambda (rpt) (multicol-report-renderer rpt 'pnl)))
> I expect there would be scope for confusion if I didn’t change lines
> 1340-1 - say prefixing “MH_” to the definitions, but I’m not sure about the
> options-generator and renderer lines.

No. these lines define the options-generator to be a procedure with no
arguments i.e. lambda () that calls (multicol-report-options-generator
'pnl). The 'pnl is used to direct the multicol-report-options-generator to
provide options suitable for profit-n-loss aka 'pnl. See the definition of
multicol-report-options-generator and locate where 'pnl is tested.

> uuidgen on my Mac issues 36-character uuids, with hyphens and uppercase,
> like this:
> 47170C69-F87E-4A3B-9A97-8B97F56F5DFD
> Would I need to edit them to give 32-character lowercase uuids, lacking
> hyphens?

Actually any unique string of any length will do.

> Obviously, I have to take responsibility for my own programming
> experiments (and errors), but I’d appreciate a quick steer from someone
> with Scheme experience. Regards,
> Michael

Good luck!

More information about the gnucash-devel mailing list