And Now In Colour

(Originally posted 2015-03-31.)

As you know, we turn data into reports and try to make sense of it. One thing we’ve not done before is use colour in our textual and tabular reports. So here’s what I’ve learnt about how to make B2H use colour.

Our Reporting Process

But first a word or two about how we get these reports.

  1. We collect SMF data into engagement-specific VSAM-based performance databases.

  2. We use canned reporting – driven by parameters – to produce GIFs and Bookmaster [1] (SCRIPT) source.

  3. For our “Job Dossier” and “Batch Suite” reporting we create Postscript and hence PDF documents.

For any other textual or tabular reports B2H converts the Bookmaster source into HTML.

B2H takes Bookmaster Source and converts to HTML.

This post could usefully be read in conjunction with Many Ways To Skin A Cat – Modernising Bookmaster / Script … which discusses some techniques for controlling B2H and handling the resulting HTML.

Why We Want Colour

  • Because it’s prettier. 🙂
  • Because we can highlight things for the specialist to look at.

As our reporting is automatically created I think it would be valuable (and possible) to have the code highlight a few things – for the specialist to take note of.

Some Techniques

Bookmaster itself has very little in the way of colour support, being from the days when colour printers were expensive and scarce. [2]

And I’d really like to – as much as possible – stick to the original Bookie source format. In case we end up going through the scripting process again. But I’m not that hard and fast about it.[3]

So let’s start with what you can do with minimal changes to the Bookie source.

Minimal Change

Let’s start with some legitimate Bookie – which is what your existing text would be. The following would script perfectly well and produce some shading: [4]

:tdef id=xlight refid=shade shade='no xlight'.
:tdef id=light  refid=shade shade='no light'.
:tdef id=medium refid=shade shade='no medium'.
:table cols='* 3*'.
:tcap.Default appearances for SHADE
:thd.:c.Shade Type :c.Actual appearance:ethd.
:row.
:c.SHADE=NO
:c.Some text with no shading
:row refid=xlight.
:c.SHADE=XLIGHT
:c.Some sample text with extra-light shading
:row refid=light.
:c.SHADE=LIGHT
:c.Some sample text with light shading
:row refid=medium.
:c.SHADE=MEDIUM
:c.Some text with medium shading
:etable.

Everything between the table and etable tags defines a table, the rows being started by row tags. Each cell in the row starts with a c tag.

Notice the refid attributes on the row tags. These refer to the tdef tags at the top. Each tdef has a shade attribute. The words in the shade attribute govern what shading each column has.

So the first tdef specifies that the first cell in any row that uses it has no shading, but the second cell has extra light shading.

Here’s how B2H formats it – and Bookie would create something very similar:

Now we can turn this into colour in B2H by adding some special comments that scripting would ignore:

Adding the following lines at the beginning creates the colour table below.

.*B2H OPTION SHADE.LIGHT=FFF0F0
.*B2H OPTION SHADE.XLIGHT=F0FFF0
.*B2H OPTION SHADE.MEDIUM=F0F0FF

These three lines are Bookmaster comments but when run through B2H they have specific effects.

Take the first statement. It says that what Bookie calls “xlight” should be shaded with the RGB [5] value FFF0F0 (or very pale red).

You’ll’ve spotted there’s nothing extra light about a RGB value of ‘FFF0F0’ (hex). Well no more than the next two (‘F0FFF0’ hex and ‘F0F0FF’ hex – which are pale green and pale blue). So you have to keep this correspondence by other means.

Something Less Clunky?

There are at least two things wrong with the above:

  • The opacity of “extra light” being translated into “very pale red”.
  • You can only pick from a palette or rows and can’t turn on shading at the individual cell level.

Consider the following Bookie:

.* light is red
.*B2H OPTION SHADE.LIGHT=FFF0F0
.* xlight is green
.*B2H OPTION SHADE.XLIGHT=F0FFF0
.* medium is blue
.*B2H OPTION SHADE.MEDIUM=F0F0FF
:tdef id=c1r3r refid=shade shade='light no light no'.
:tdef id=c1r3g refid=shade shade='light no xlight no'.
:tdef id=c1r3b refid=shade shade='light no medium no'.
:tdef id=c1g3r refid=shade shade='xlight no light no'.
:tdef id=c1g3g refid=shade shade='xlight no xlight no'.
:tdef id=c1g3b refid=shade shade='xlight no medium no'.
:tdef id=c1b3r refid=shade shade='medium no light no'.
:tdef id=c1b3g refid=shade shade='medium no xlight no'.
:tdef id=c1b3b refid=shade shade='medium no medium no'.
:table cols='* * * *'.
:tcap.Columns 1 And 3 Have Coloured Backgrounds
:thd.
:c.First Column
:c.Second Column
:c.Third Column
:c.tdef
:ethd.
:row refid=c1r3r.
:c.A
:c.B
:c.C
:c.c1r3r
:row refid=c1r3g.
:c.D
:c.E
:c.F
:c.c1r3g
:row refid=c1r3b.
:c.G
:c.H
:c.I
:c.c1r3b
:row refid=c1g3r.
:c.J
:c.K
:c.L
:c.c1g3r
:row refid=c1g3g.
:c.M
:c.N
:c.O
:c.c1g3g
:row refid=c1g3b.
:c.P
:c.Q
:c.R
:c.c1g3b
:row refid=c1b3r.
:c.S
:c.T
:c.U
:c.c1b3r
:row refid=c1b3g.
:c.V
:c.W
:c.X
:c.c1b3g
:row refid=c1b3b.
:c.Y
:c.Z
:c.!
:c.c1b3b
:etable.

It produces the following table – with B2H.

The intended effects are:

  • Columns 1 and 3 are shaded – in turn red, green and blue.
  • Column 2 is never shaded.
  • Column 4 is never shaded but documents the tdef id. I’ve adopted a naming convention for the tdef ids that encodes the column number and its notional value. For example “c1b3r” means “column 1 blue and column 3 red”.

This is the minimum you need to shade all 9 combinations of columns 1 and 3.

It’s really very cumbersome – but perfectly programmable. For applications (such as mine) where maybe only 1 or 2 cells in a row require “smart shading” this might be acceptable.

Also cell shading – while what I will probably want most if the time – is not the only effect that HTML is capable of. (Even if we restrict ourselves to CSS and don’t use javascript.)

It’s the most you can do with “pure” Bookie (but with B2H comment instructions). Or is it?

As noted in Many Ways To Skin A Cat – Modernising Bookmaster / Script … you can add HTML in B2H comments (which Bookie will ignore).

So one thing to try is using the style attribute on a div element within a cell. Here’s how you might code it:

:c.
.*b2h html <div style='background-color: lightblue; display: inline-block;width: 100%;'>
Some sample text with a background.
.*b2h html </div>

In this the c tag is followed by a B2H line to add a div element, with styling. Then we have the actual text to put in the cell. And finally an end div tag.

In this case we set the background colour to a (standard) light blue. The display: inline-block; width: 100% ensures the background colour fills the cell.

The cell looks something like this:

This, of course, can be done at the individual cell level. And it’s easy for a program to generate lines like these new ones.

One nice thing about this technique is you can apply arbitrary CSS to a table cell. For example setting the foreground colour with e.g. color: red;.

Colouring A Heading

It’s perfectly possible to set the format of any heading level. Taking an example from the B2H manual:

.*b2h option headrec.text='<style type="text/css">'
.*b2h option headrec.text='H1    { font-size: x-large; color: red  }'
.*b2h option headrec.text='H2    { font-size: large;   color: blue }'
.*b2h option headrec.text='</style>'

says that all h1 elements will be red. h2 elements will all be blue.

You’d put this at the top of the source.

Colouring Arbitrary Text

In many places in Bookmaster you can use Highlighted Phrases. These are coded somethng like:

Here is some :hp4.highlighted:ehp4. text.

You can define what each highlighted phrase looks like. I’m going to use the example of hp9 which is probably one you’s not normally use. Here’s how you specify its formatting to B2H:

.*b2h symbol :TAG.  HP9 IT=N VAT=N ATT=N SE=Y V='<span style="color: red;">'
.*b2h symbol :TAG.  EHP9 IT=N VAT=N ATT=N SE=Y V='</span>">'
:p.Here is some :hp9.highlighted:ehp9. text.

which formats as:

Conclusion

As I think I’ve shown it’s perfectly easy to enhance Bookmaster source so that when formatted with B2H it adds a dash of colour. More than an em-dash, in fact. 🙂

Now to find places to use it.


  1. Affectionately known as “Bookie”.  ↩

  2. But who said anything about printing? 🙂  ↩

  3. If you have a professional interest in this it’s because you have an application to maintain that you want to modernise to, for example, add a splash of colour.  ↩

  4. In this post I’m using screen grabs rather than inline HTML. That way the results should be consistent, wherever you read the post.  ↩

  5. Red, Green & Blue.  ↩

Published by Martin Packer

I'm a mainframe performance guy and have been for the past 35 years. But I play with lots of other technologies as well.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: