This is one of my miscellaneous projects and its status is work in progress.

Label Generation Software

In my garage, I have lots and lots of drawers. Indeed, I have so many drawers that I can not remember what is in all of them. My solution to this problem is to put labels on the outside of all the drawers so that I know what the drawer contents are. I have written some simple software to generate label files. Since this software is written in STIPPLE, I expect it to be basically useless for anybody except me.

There are three files that are used in concert to produce labels:

Template File (.template)
The template file specifies the basic layout of the the label output file. Special characters are inserted into the template file that specify where values can be substituted in.
Mapping File (.mapping)
The mapping file indentifies the various fields withing the template file.
Value File (.values)
The values file specifies a list of values that can be substituted into the labels. The values file is designed so that it is possible to just keep appending new label values into the file. This means that damaged labels can be trivally regenerated by just specifying the number of the damaged label.
For a given set of labels, all three files use the same base name with a different suffix to distinguish between the files.

The template file looks something like the example below:

    +-------------------------+  +-------------------------+
    |                         |  |                         |
    | $$$$$$$$$$$$$$$$$$$$$$$ |  | $$$$$$$$$$$$$$$$$$$$$$$ |
    |                         |  |                         |
    | $$$$$$$$$$$$$$$$$$$$$$$ |  | $$$$$$$$$$$$$$$$$$$$$$$ |
    |                         |  |                         |
    +-------------------------+  +-------------------------+

    +-------------------------+  +-------------------------+
    |                         |  |                         |
    | $$$$$$$$$$$$$$$$$$$$$$$ |  | $$$$$$$$$$$$$$$$$$$$$$$ |
    |                         |  |                         |
    | $$$$$$$$$$$$$$$$$$$$$$$ |  | $$$$$$$$$$$$$$$$$$$$$$$ |
    |                         |  |                         |
    +-------------------------+  +-------------------------+
								
The example above has four labels, where each label has two fields. The fields are indicated by the strings of dollar signs "$$$...$$$". There is nothing magical about the choice of a dollar sign as the label field indicator, any character can be used; however, it is easier if a character that is not otherwise used in the template file is used. In the example above, percent (%) or at-sign (@) would work just as easily as dollar sign, but plus sign (+) and minus sign (-) would be much more tedious.

The mapping file consists of ordered triples of the form:

   {Label_number} {Field_number} {Characters}
								
where each field is used as follows:
Label_number
Label number is the number of the label in the template file.
Field_number
Field number is the field number for the label.
Characters
The first character is the character that identifies the next field in the template file (e.g. dollar sign ($).) The remaining characters control value substitution in the field. They are selected from the following catagories:
Justification
C (default)
Center the value in the field.
L
Left justify the value in the field.
R
Right justify the value in the field.
Padding
P (default)
Pad the value in the field with spaces to exactly match the number of characters in the template file.
N
No padding in added to the value before substitution.
Truncation
i (default)
Insert any values that are too big for a field without any truncation.
l
Truncate values that do not fit by removing characters from the left.
r
Truncate values that do not fit by removing characters from the right.
Error Reporting
E (default)
Error messages are generated for any values that do not fit in a field without truncation or insertion.
S
Silently ignore any values that do not fit within a field without truncation or insertion.
Comment lines start with a sharp sign (#). And blank lines are totally ignored.

The mapping file for the template example above is:

1 1 $C
2 1 $C
1 2 $C
2 2 $C
3 1 $C
4 1 $C
3 2 $C
4 2 $C
								
This mapping file basically says that the first sequence of dollar signs in the file corresponds to the first field of the first label, second sequence corresponds to the first field of the second label, the third sequence corresponds to the second field of the first label, etc. All fields are centered, with error reporting left on by default.

The values file has the following format:

    {label_name}: {field_value1} ... {field_valueN}
								
Continuation lines are indicated by just starting them with some sort of whitespace (space or tab.) Comments are lines that start with a sharp sign (#). The field values consist either of a single word, where a word is defined as any sequence of characters not including a space, or a quoted string. The quoted string can use either single quotes (') or double quotes ("). For now, there is no escape character within quoted strings.

An example label file looks as follows:

1: "1/4 Inch #6 32 TPI" "Round Head Machine Screws"
2: "3/8 Inch #6 32 TPI" "Round Head Machine Screws"
3: "1/2 Inch #6 32 TPI" "Round Head Machine Screws"
4: "5/8 Inch #6 32 TPI" "Round Head Machine Screws"
5: "3/4 Inch #6 32 TPI" "Round Head Machine Screws"
6: "1 Inch #6 32 TPI" "Round Head Machine Screws"
								
For this example, each label has two fields. The labels are given the unimaginative names of 1 through 6.

The labelgen program is used to generate the labels. The command line arguments for labelgen are:

labelgen basename labelname1 ...
where
basename
is the base name of the template, mapping, and value files.
labelname1
is the label name in the label file.
The output is written to standard out.

There are some other files associated with this project:

labelgen.sts
The labelgen source code. (Remember, this source code is written in STIPPLE, so there is a good chance that you really do not want to bother with looking at it.
makefile
The Makefile that builds the labelgen program.
organizer.template
A template file for my 50-drawer organizer cabinets.
organizer.mapping
A mapping file for my 50-drawer organizer cabinets.
organizer.values
A values file for my 50-drawer organizer cabinets.


Copyright (c) 1997 -- Wayne Gramlich All rights reserved.