Output of file : SNKCOL.ART contained in archive : DB3-ART.ZIP
Snaked Column Reporting
BY SOFTWARE SUPPORT TECHNICIANS
If you need to print directories, parts lists, or catalogs you may have
wondered how to create a report in which the columns wrap like a standard
phone book. You probably realized quite quickly that REPORT FORM cannot wrap
from one column to the next, although it can wrap within a column. You may
then have viewed LABEL FORM with a hopeful eye, but found that although you
can create column reports, you cannot create a column of records and then
place beside it another column of records. What you need is a custom report
program that performs the application for you. The following program,
Snake.PRG, does exactly this.
Snaked column reporting if you are not familiar with the term refers to the
way column contents are laid out on the page. In a standard column-oriented
report such as REPORT FORM, columns are report fields where each row or group
of rows is derived from a record in your database file or View. Columns are
related by row. Snaked column reports, by contrast, are like newspaper
columns. Row order exists only within a column and not across columns. Page
columns are linked bottom to top, the last record in the first column is
followed by the first record in the second column giving you the snaking
effect. Figure 1 gives you a graphic illustration of the relationship of
columns and rows.
Snake.PRG is designed to be as easy to use and automatic as possible.
Basically all you do to run it is to pass parameters for the data definition
(database file, index file, and filter condition), page format (header and
footer), and column definition (column heading, column contents expression,
and record number flag). The program figures out the rest and based on a
series of configurable memory variables listed at the top of Snake.PRG, prints
Each report page has standard dimensions you can change in the definition
memory variable table mentioned above. When the snake column report prints
each column is separated by a configurable delimiter string in addition to the
beginning and end of each row. The default value of this string is the
character "|", but you can make it any character or string of characters you
want. The delimiter variable is not a passed parameter but is initialized in
the user definition table at the top of Snake.PRG.
The column contents is an expression that outputs the display for each
column. This expression must be character type and can consist of fields,
memory variables, and literal strings. When Snake places the result of the
contents expression in the column, it always left-justifies it within the
column. If you need to print two fields within a column, one left-justified
and one right-justified, your contents expression must take this into
For example, suppose you have two fields, Name and Phone. In your snaked
column report, you want to print Name left-justified and Phone
right-justified, separated by a series of dots like the following:
Jack Smith .......... 555-1212
Marilyn Smith ....... 555-1212
To accomplish this, pass the following as the column contents expression
parameter on the DO Snake command line:
The consideration here is that the column length must be known prior to
running the report since it is used to determine the number on intermediate
characters between the left-justified field and the right-justified field.
Snake fortunately has a feature that accounts for this. If you want to find
out the column width from the parameters you pass, create a numeric memory
variable "colwidth." Then DO Snake WITH your report parameters. If
"colwidth" exists, Snake calculates report column width placing it in
"colwidth" and RETURNs to the calling program without printing the report.
With this facility, you can DO Snake once to obtain the column width and then
use the value returned as a part of the report field expression if it needs
the column width as an argument. For example,
colwidth = 0
* ---Run Snake to determine the report width.
DO Snake WITH
* ---Assign "colwidth" to variable you can use in your report
* ---field expression and get rid of the "colwidth" so your
* ---report will print.
newidth = colwidth
* ---Run Snake with the real parameter list using "newidth"
* ---in the report field expression.
DO Snake WITH
Snake provides some other features. These include optional page, record
numbering, and column delimiter. Specifying the string "<#>" in either the
header or footer expression places the current page number in the position
where you placed the special symbol. Specifying 0, 1, or 2 for the record
number flag determines whether an optional record number is placed next to
each record's contents. Zero suppresses the automatic numbering, 1 places the
actual record number beside the record contents, and 2 places a number
representing the position of the record in the printed list. You can as well
specify a column heading that is placed left-justified above each column on
every page of the report.
To set up, create the file Snake.PRG using the text editor of your choice.
Then enter the program code for Snake and the procedures Reptproc, Spacing,
and Getpage into Snake.PRG. If this seems a little strange, don't be
alarmed. dBASE III PLUS permits a command file to SET PROCEDURE TO itself.
If you wish to change any of the fundamental behaviors of the report, you can
change any of the variables in the user definition table at the top of
Snake.PRG. For specific instructions as to the legal values for variables
refer to the comments within the table.
In order to begin the program from the dot prompt issue the following command: