home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
rptform.zip
/
REPORT2
< prev
next >
Wrap
Text File
|
1987-02-01
|
11KB
|
310 lines
REPORT FORM - THE dBASE REPORT GENERATOR
========================================
Part 2
Last month we reviewed how to define the contents of a column in REPORT
FORM (among other things). This month, let's begin by examining other
aspects of defining columns in a report such as the column widths and
column headings.
REPORT FORM COLUMN WIDTHS
=========================
The column width for each REPORT FORM column or field defaults to the
combined width of all items placed within the field/column - even when ";"
is used to create multiple data lines within the column. This can be
overridden by simply typing in the desired width of the column in the box
presented for each field.
When the field or column width is set to less than the width of the
contents (assuming no ";" has been used), REPORT FORM will wrap the
remainder of the contents to the next line. dBASE tries very hard to place
the data within the column so information in character strings is not
split, except where blanks occur. If dBASE can not find any handy blanks
between concatenated strings, some data may end up on a lower line. If
this happens simply MODIFY STRUCTURE by placing a SPACE() between data
fields at the wrap point:
FIELD1 + SPACE(1) + FIELD(2)
When the report is printed the SPACE() or blank field will be "lost".
However, the SPACE() is reflected in the default REPORT FORM field width
count.
Be particularly careful about column width settings when MODIFYing REPORT.
If there are columns in your REPORT FORM where you have set the width to
less than the dBASE default width, making changes in that column will
return the width to the dBASE default. It is necessary to again override
the dBASE default by specifying the column width.
This nasty little bug has been present since release 1.0 dBASE III and has
carried through all the way to release 1.1 of dBASE III PLUS. Apparently
Ashton-Tate does not see it as a real problem, but if you make good use of
REPORT FORM and MODIFY REPORT it can become a serious difficulty.
COLUMN/FIELD HEADINGS
=====================
dBASE views all column or field headings as character strings. Memory
variables can NOT be used in the column headings, nor can macros.
When the character string for the column heading is wider than the contents
of the column, REPORT FORM automatically adjusts the column width to the
width of the column heading. However, you can override this by choosing
the column width option and setting your own column width.
In this case, when the column heading is wider than the specified width of
the column, dBASE will wrap the heading and print it on more than one line.
Thus, in addition to the four column heading lines provided by the REPORT
FORM, dBASE can be tricked into providing additional lines of column/field
headings.
Column or field headings for columns which contain character type data are
automatically left justified by dBASE.
The Report Generator automatically right justifies column (field) headings
for numeric fields when the report is printed. This can be changed by
converting the numeric fields to character fields with the STR() function
when creating your report:
STR(NUMFIELD)
In this case dBASE will treat the numeric field as a character field.
Remember, however, you may have to adjust for the decimal places - and the
ability to subtotal and total numbers will be eliminated.
SPACE() With REPORT FORM
========================
Because the report generator left justifies data and headings in character
columns/fields and right justifies numeric data, the two spaces dBASE
automatically places between columns often do not provide enough room
between columns for a good looking report. SPACE() can be used to insert a
column in between to obtain that better appearance. Simply enter the
SPACE() statement with the desired number of spaces in its own field
contents box. The following would provide a blank column of five spaces
between data columns:
SPACE(5)
SPACE() can also be used to force the wrap-around feature of the column
headings and provide more than the allotted four heading lines in the Field
header box:
Field 1. DEPARTMENT + SPACE(20) + DATE HIRED
header 2. SPACE(2) + TITLE
3. SPACE(3) + SALARY
4. SPACE(4) + PHONE
would produce a print-out of the field or column header this way:
DEPARTMENT
DATE HIRED
TITLE
SALARY
PHONE
GROUP TOTAL AND SUBTOTAL HEADINGS
=================================
When using totals and subtotals in a report, dBASE begins listing data
immediately after the heading description for groupings and subgroupings.
Having a blank line between the group or subtotal headings (and the
subgroup/subtotal headings) and the data under each heading makes a much
nicer looking report.
The manuals don't mention that this can be done, but it is possible.
Because dBASE will wrap any group heading longer than the width of the
report, you can trick REPORT FORM into giving you this nice appearance by
using the SPACE() function.
First of all, make sure your printer is set for wrap-around printing. How
to accomplish this varies with the different makes and models of printers
and, therefore, can not be addressed here. You will need to refer to your
printer manual.
In REPORT FORM, include the statement
SPACE(n) + "."
after the statements of the data field(s) upon which the report form will
be grouped or subtotaled:
DEPT + SPACE(75) + "."
Placing this type of a statement in the "Group heading" or "Sub-group
heading" boxes has no effect since, in the actual report, the information
is displayed as:
* <Group Heading>: <Group Expression>
** <Sub-Group Heading>: <Sub-Group Expression>
The actual length of the space would depend upon whether you are using 80
or 132 column paper and the length of the data field(s) upon which you are
grouping or subtotaling.
Although dBASE will "wrap" to give you a blank line, it does not increase
it's line counter with the wrap. Therefore, you will need to adjust the
number of lines per page accordingly. I usually change the lines per page
option from the default of 58 lines per page to 56 per page. However, if
you anticipate having many different groupings on each page this would have
to be decreased even further.
OPTIONAL PAGE HEADINGS FOR REPORTS
==================================
There are so many different types of headings possible in REPORT FORM that
it can really become confusing. This section refers to headings which are
not created in the REPORT FORM itself but, rather, by using the HEADING
option statement when issuing the command which will initiate the report:
REPORT FORM xxxx HEADING xxxx NOEJECT TO PRINT
The HEADING statement must be a character expression. Numeric, Date, and
Logical types are not accepted. Any combination of memory variables, data
fields (including aliases), and functions is acceptable as long as all data
types are character.
Therefore, it is necessary to convert dates to character strings with the
DTOC() function and to change numeric information to character strings with
the STR() function. As an example, to include the current date in an
optional heading, the following statements would be required:
STORE DTOC(DATE()) TO CDAY
REPORT FORM xxxxxx HEADING "AS OF " + CDAY
or
REPORT FORM xxxxxx HEADING "AS OF " + DTOC(DATE())
As you might gather from the above example, REPORT FORM can use variable
data without macro substitution. As an example, create a memvar called
TITLE:
TITLE = "Test Heading Option"
and print the report using the following statement:
REPORT FORM xxxx HEADING TITLE NOEJECT TO PRINT
And you will see a title line saying "Test Heading Option" appear above the
header lines included in the REPORT FORM itself.
Using a field from the database in use in the HEADING option provides a
wide range of possibilities. When the data field is included the informa-
tion from the field in the record to which the pointer is directed will be
printed or displayed. (dBASE then goes to the top of the file to begin the
report.)
Assume, for instance, you have a database which is a master list of
patients (PATIENT) and another database which is a record of visits made
(VISIT). You want to generate a report listing all visits made to a
particular patient, with the patient's name printed at the top of the
report. However, the VISIT database records do not contain the patient's
name, just the patient's ID number. So we must first go to the PATIENT
database to find the patient and his/her ID number:
SELECT 1
USE PATIENT INDEX PNAME
SELECT 2
USE VISIT INDEX VDATE
STORE SPACE(20) TO MEMFIRST, MEMLAST
* ----------------------------------------------------------
* User enters name of patient
* ----------------------------------------------------------
CLEAR
@ 2,5 SAY "Enter patient's first name: " GET MEMFIRST PICTURE "@A!"
READ
@ 4,5 SAY "Enter patient's last name: " GET MEMLAST PICTURE "@A!"
READ
SELECT PATIENT
STORE MEMFIRST + MEMLAST TO LOOKUP
SEEK LOOKUP
* ----------------------------------------------------------
* Patient record located
* ----------------------------------------------------------
SELECT VISIT
REPORT FORM VREPORT HEADING TRIM(PATIENT->FNAME) + ;
" " + PATIENT->LNAME FOR IDNO = PATIENT->IDNO
* ----------------------------------------------------------
* Visit report generated
* ----------------------------------------------------------
RETURN
The Ashton-Tate manuals lead one to believe that only one optional heading
line is available. However, it is possible to trick dBASE into supplying
multiple line optional headings. This is because the optional heading will
wrap around at 40 columns or characters.
While the 40 column wrap may present a problem for some, it can be used
effectively to obtain multiple line optional headings by including the
SPACE() option in your headings:
REPORT FORM xxxx HEADING "EXAMPLE UNIVERSITY" + SPACE(32)
+ "Department of Physics"
The semi-colon (without quotes) can also be used to obtain multiple line
optional headings:
REPORT FORM xxxx HEADING "EXAMPLE " ; + "Department of Physics"
The HEADING option and the PLAIN option can NOT be used together. The
PLAIN option cancels the HEADING option, so your optional heading would not
appear on the report.