REPORT FORM - THE dBASE REPORT GENERATOR Part 4

                    REPORT FORM - THE dBASE REPORT GENERATOR

                   ========================================


                                   Part 4






Last month we took a look at how to use REPORT FORM to produce reports

displayed on screen and how to print out "plain vanilla" reports.  This

month we'll take a look at some of the ways you can use REPORT FORM in

combination with your printer control codes and/or upper ASCII characters

to produce fancy and elegant reports.


The appearance of a report is just as important as the accuracy of the data

it contains and the extra work involved is well worth while.  As crazy and

illogical as it may seem, I have time and time again seen clients enthuse

about a printed report with a good appearance even when the information

contained in the report has disastrous implications.  (Another triumph of

form over substance.)


The CHR() function in dBASE, FoxBASE, Clipper and Quicksilver can be used

to send printer control codes that instruct the printer to set bold on or

off, set underlining on and off, change fonts, etc.  This can be done

before you issue the REPORT FORM xxxxx TO PRINT command or from within the

REPORT FORM .FRM file itself.


Unfortunately, different printers use different sets of printer control

codes just as different printers will print differing characters for the

upper ASCII set.  (Heaven forbid the industry should standardize!) 

Therefore, I am unable to be of much help to you in determining the exact

values to be used for your particular printer.  


For purposes of illustration in this article I will be using control codes

for the Toshiba P351 and P351C printers and codes that will work with most

Epson printers.  You will have to refer to the manual for your particular

printer to determine the values you will need to use.  However, you might

want to know that many of the Epson control codes are the same as those

used in Okidata printers and IBM printers.  Therefore, many of the examples

provided here for the Epsons may work with those printers.  (I don't happen

to have either Okidata or IBM printers or manuals so could not test this

out for you.)


Most printer manuals have a section - or even a chart - giving the Escape

Sequences, Hexadecimal and Decimal values to enable their various features. 

You need to look for the Decimal values.  These are the numbers that will

be placed in the CHR() function.


For example, in the Toshiba manuals the decimal values of 27 69 are listed

as the codes to turn on the emphasized print.  This would translate to the

following statement in dBASE or FoxBASE (assuming you have issued the

command SET PRINT ON):


        ?? CHR(27) + CHR(75)



The dBASE statement to turn on emphasized or bold print for most Epson

printers is:


        ?? CHR(27) + CHR(69)



To turn off the bold or emphasized print on a Toshiba P351 or P351C printer

the dBASE statement is:


        ?? CHR(27) + CHR(77)


and for most Epson printers the statement is:


        ?? CHR(27) + CHR(70)


Unlike the single question mark which sends a line feed control to the

printer, the double question mark sends the information to the printer

without a line feed.


Armed with this information we could print out a report with the optional

heading and use the control codes to print that optional heading in bold or

emphasized print, then turn the bold off.  The remainder of the report

would be printed in the normal print.


For the Toshiba P351 and P351C printers the statement would be:


        USE <database> INDEX <whatever>

        REPORT FORM xxxxx HEADING CHR(27) + CHR(75) + "THIS HEADING;

          SHOULD BE PRINTING IN BOLD" + CHR(27) + CHR(77) TO PRINT


While for most Epson's the statement would be:


        USE <database> INDEX <whatever>

        REPORT FORM xxxxx HEADING CHR(27) + CHR(69) + "THIS HEADING;

          SHOULD BE PRINTING IN BOLD" + CHR(27) + CHR(70) TO PRINT


The printer control codes inserted just before the information in quota-

tions that will be printed as the optional heading instruct the printer to

turn ON the bold or emphasized print.  The printer control codes immediate-

ly after the information in quotations instructs the printer to turn OFF

the bold print.  Therefore, the body of the report will be printed in the

normal print style.


dBASE and FoxBASE are supposed to center the optional heading, however,

including the printer control codes sometimes skews the centering. 

Therefore, you may have to juggle things a little bit by inserting a blank

or space or two right after the initial heading data:


        REPORT FORM xxxxx HEADING CHR(27) + CHR(69) + "   THIS HEADING;

          SHOULD BE PRINTING IN BOLD" + CHR(27) + CHR(70) TO PRINT


Your needs will depend a lot upon your particular printer.  However, it is

easy enough to do a test printing to determine whether you will need the

blank spaces and then insert them in your code.


Underlining is a feature many like in their reports.  For the Toshibas the

dBASE statement to turn on underlining is:


    ?? CHR(27) + CHR(73)


and the following statement is used to turn underlining off:

    

    ?? CHR(27) + CHR(74)


Epson printers seem to work in a slightly different way.  The same decimal

values are used to both turn underlining on and turn it off.  The statement

is:


    ?? CHR(27) + CHR(45)


The first time most Epson printers encounter these printer control codes

they turn on the underline feature.  The next time they are encountered the

underline is turned off.


Using this information we could then create a printed report with the

optional heading underlined and the remainder of the report printed in the

normal manner:


For the Toshiba P351 and P351C printers the statements would be:


        USE <database> INDEX <whatever>

        REPORT FORM xxxxx HEADING CHR(27) + CHR(73) + "THIS OPTIONAL;

          HEADING SHOULD BE UNDERLINED" + CHR(27) + CHR(74) TO PRINT


and the statement for most Epson printers would be:


        USE <database> INDEX <whatever>

        REPORT FORM xxxxx HEADING CHR(27) + CHR(45) + "THIS OPTIONAL;

          HEADING SHOULD BE UNDERLINED" + CHR(27) + CHR(45) TO PRINT



We could get even fancier and have the optional heading printed out in bold

or emphasized and underlined at the same time.  The Toshiba P351 and P351C

statements would be:


        USE <database> INDEX <whatever>

        REPORT FORM xxxxx HEADING CHR(27) + CHR(75) + CHR(27) + CHR(73);

          + "THE OPTIONAL HEADING SHOULD BE IN UNDERLINED BOLD" +

          CHR(27) + CHR(77) + CHR(27) + CHR(74) TO PRINT


while most Epsons would use the following code:


        USE <database> INDEX <whatever>

        REPORT FORM xxxxx HEADING CHR(27) + CHR(69) + CHR(27) + CHR(45);

          + "THE OPTIONAL HEADING SHOULD BE IN UNDERLINED BOLD" +

          CHR(27) + CHR(70) + CHR(27) + CHR(45) TO PRINT


Of course, there are instances where you may want to change all of the

print in a particular report.  A good example is use of the compressed

print style for very wide reports.  In this instance you simply SET PRINT

ON and send the printer control code.


The code to turn on the compressed print for the Toshiba printers, print

the report, and then turn off the compressed print would look like this:

    

        USE <database> INDEX <whatever>

        SET PRINT ON

        ?? CHR(27) + CHR(91)

        REPORT FORM xxxxx TO PRINT

        EJECT

        ?? CHR(27) + CHR(93)

        SET PRINT OFF

        

Many printers, including most Epsons and Okidatas use the 015 value to set

the compressed print on and the 018 value to set the compressed print off:


        USE <database> INDEX <whatever>

        SET PRINT ON

        ?? CHR(27) + CHR(15)

        REPORT FORM xxxxx TO PRINT

        EJECT

        ?? CHR(27) + CHR(18)

        SET PRINT OFF


One of the many things your dBASE manuals do not tell you is printer

control codes can be inserted directly in the REPORT FORM you create.  This

opens up a whole new world of possibilities for producing printed reports

with an elegant appearance!  


How about a report with the column headings printed in bold and a letter-

quality print style while the remainder of the report is printed in the

standard draft mode?  Or a report where a person's ID number, name, ad-

dress, and phone are all in one column but one specific piece of the data

set is printed in bold and another underlined.  For reports that contain

groupings or totals by group or subgroup the descriptions of the group or

subgroup could be printed in bold and/or underlined.


We'll take a look at ways to do this next month.




Comments

Popular posts from this blog

BOTTOM LIVE script

Evidence supporting quantum information processing in animals

ARMIES OF CHAOS