< ] [ GCL Home ] [ CGI Tutorial ] [ Home ] [ > ]

The Graphic Counter Language, Page 5

Sometimes, it is useful to add a head and a tail to the counter.

The head is a graphic placed to the left of the counter, the tail to the right.

I have found some interesting GIF pictures at the Museum of Counter Art. The particular set I have chosen for this example consists of files 0realaba.gif - 9realaba.gif, left.gif, and right.gif, designed by Ashley Chang. (Note, in the ZIP I downloaded from the museum, they were all upper-case names, but I renamed them to lower case, matter of personal preference.)

These graphics are “self-framing,” i.e., the frame is built into each graphic. All we need to do, is write a GCL program to combine them into a graphic.

Adding Head and Tail

GCL has the #: command to add a head graphic, and the #. for the tail. Their syntax is the same as for listing any other graphic before.

This particular counter requires no added frame, no kerning, no alignment, and no padding. All we have to do is list all the graphics.

Setting the Start Value

In GCL you can also set the start value of the counter. For example, to set it to 1000, add count = 1000 to the source file. We will do that in our example.

Now, let’a see the complete source code for our abacus.gcl counter program:

#!/usr/bin/gcl
#0 "/usr/pix/0realaba.gif" gif
#1 "/usr/pix/1realaba.gif" gif
#2 "/usr/pix/2realaba.gif" gif
#3 "/usr/pix/3realaba.gif" gif
#4 "/usr/pix/4realaba.gif" gif
#5 "/usr/pix/5realaba.gif" gif
#6 "/usr/pix/6realaba.gif" gif
#7 "/usr/pix/7realaba.gif" gif
#8 "/usr/pix/8realaba.gif" gif
#9 "/usr/pix/9realaba.gif" gif
#: "/usr/pix/left.gif" gif
#. "/usr/pix/right.gif" gif
count = 1000

Copyright © 1999 G. Adam Stanislav
All rights reserved

That's all there is to it! A full GCL program in just 14 lines.

The result is below. It is not necessarily showing the count of 1000. That was the start value, and is increased every time you load or reload this page.

Click on the counter to come to page 6 where we discuss the creation of vertical counters.

< ] [ GCL Home ] [ CGI Tutorial ] [ Home ] [ > ]