Robert Shiplett's Blog

2 Posts tagged with the yahoo tag
2

My second iteration has added another TocDocument but this one has a procedure to populate an index entry and its pages.

That procedure might also be a place to add the values to a printable container should a user wish to print the index.

The procedure definition below follows the declaration of 2 variables which we will populate on each call.

{let public v1:#Visual, v2:#Visual}
{define-proc public {idx-entry entry:String, pages:String}:(Visual, Visual)

The procedure returns two visual objects which ensures that all entries and pages are formatted with the same look-n-feel.

A typical call might be

{set (v1, v2) = {idx-entry "parse", "369"}}
{heading level=4, {value v1}}
{heading level=5, {value v2}}

which is often preferrable to the simpler, error-prone and no-fun-to-maintain repetition of sequences such as

{heading
level=4,
{paragraph
paragraph-left-indent = 0.25in,
{bold parse}
}
}
{heading
level=5,
{paragraph
paragraph-left-indent = 0.50in,
{text
text-preserve-whitespace?=true,
text-breakable?=false,
369
}
}
}

for each entry.

With the simple abstraction which the procedure provides, we can change the layout in one place and we can consider adding a facility such that the user could customize the index and retain their changes as client-side persistent data. All of which points to a role for Curl in The-Future-of-the-Book, n'est-pas?

The complete procedure follows:

{define-proc public {idx-entry entry:String, pages:String}:(Visual, Visual) || TocTreeItem
{return
{paragraph
paragraph-left-indent = 0.25in,
{bold {value entry}}},
{paragraph
paragraph-left-indent = 0.50in,
{text
text-preserve-whitespace?=true,
text-breakable?=false,
{value pages}
}
}
}
}

You no doubt see many opportunities to improve this (the user is required to remember to add spaces between page numbers or otherwise format the string of page numbers; there are no options yet to control the font, emphasis etc)

2 Comments 0 References Permalink
3

Folks,

Within the limits of a personal Curl license, I have started testing some Curl pages over at my www.LogiqueWerks.com

I'll try to keep y'all posted here at this blog of progress and hiccups at that site.

The next page up will be a TocDocument to supplement the index of one of the available books on Curl.

In the past my Curl blogs were at www.eclectic-pencil.com and www.eclectic-pencil.blogspot.com but very likely now they will be home to my related interests in Smalltalk, Rebol, Icon, Unicon, Converge, Oz, Jython and such while my Curl blogging moves to this address.

There are two open source modules for Python that I intend to port to Curl, so their progress should also track from this blog.

Cheers

3 Comments 0 References Permalink

Robert Shiplett's Blog

Notes from the workday of a lead Curl developer at a commercial software house specializing in integrated financial packages for audit, governance, compliance and enterprise risk assessment and management