home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / rptform.zip / REPORT4 < prev    next >
Text File  |  1987-04-06  |  9KB  |  207 lines

  1.                    REPORT FORM - THE dBASE REPORT GENERATOR
  2.                    ========================================
  3.  
  4.                                    Part 4
  5.  
  6.  
  7.  
  8.  
  9.  
  10. Last month we took a look at how to use REPORT FORM to produce reports
  11. displayed on screen and how to print out "plain vanilla" reports.  This
  12. month we'll take a look at some of the ways you can use REPORT FORM in
  13. combination with your printer control codes and/or upper ASCII characters
  14. to produce fancy and elegant reports.
  15.  
  16. The appearance of a report is just as important as the accuracy of the data
  17. it contains and the extra work involved is well worth while.  As crazy and
  18. illogical as it may seem, I have time and time again seen clients enthuse
  19. about a printed report with a good appearance even when the information
  20. contained in the report has disastrous implications.  (Another triumph of
  21. form over substance.)
  22.  
  23. The CHR() function in dBASE, FoxBASE, Clipper and Quicksilver can be used
  24. to send printer control codes that instruct the printer to set bold on or
  25. off, set underlining on and off, change fonts, etc.  This can be done
  26. before you issue the REPORT FORM xxxxx TO PRINT command or from within the
  27. REPORT FORM .FRM file itself.
  28.  
  29. Unfortunately, different printers use different sets of printer control
  30. codes just as different printers will print differing characters for the
  31. upper ASCII set.  (Heaven forbid the industry should standardize!) 
  32. Therefore, I am unable to be of much help to you in determining the exact
  33. values to be used for your particular printer.  
  34.  
  35. For purposes of illustration in this article I will be using control codes
  36. for the Toshiba P351 and P351C printers and codes that will work with most
  37. Epson printers.  You will have to refer to the manual for your particular
  38. printer to determine the values you will need to use.  However, you might
  39. want to know that many of the Epson control codes are the same as those
  40. used in Okidata printers and IBM printers.  Therefore, many of the examples
  41. provided here for the Epsons may work with those printers.  (I don't happen
  42. to have either Okidata or IBM printers or manuals so could not test this
  43. out for you.)
  44.  
  45. Most printer manuals have a section - or even a chart - giving the Escape
  46. Sequences, Hexadecimal and Decimal values to enable their various features. 
  47. You need to look for the Decimal values.  These are the numbers that will
  48. be placed in the CHR() function.
  49.  
  50. For example, in the Toshiba manuals the decimal values of 27 69 are listed
  51. as the codes to turn on the emphasized print.  This would translate to the
  52. following statement in dBASE or FoxBASE (assuming you have issued the
  53. command SET PRINT ON):
  54.  
  55.         ?? CHR(27) + CHR(75)
  56.  
  57.  
  58. The dBASE statement to turn on emphasized or bold print for most Epson
  59. printers is:
  60.  
  61.         ?? CHR(27) + CHR(69)
  62.  
  63.  
  64. To turn off the bold or emphasized print on a Toshiba P351 or P351C printer
  65. the dBASE statement is:
  66.  
  67.         ?? CHR(27) + CHR(77)
  68.  
  69. and for most Epson printers the statement is:
  70.  
  71.         ?? CHR(27) + CHR(70)
  72.  
  73. Unlike the single question mark which sends a line feed control to the
  74. printer, the double question mark sends the information to the printer
  75. without a line feed.
  76.  
  77. Armed with this information we could print out a report with the optional
  78. heading and use the control codes to print that optional heading in bold or
  79. emphasized print, then turn the bold off.  The remainder of the report
  80. would be printed in the normal print.
  81.  
  82. For the Toshiba P351 and P351C printers the statement would be:
  83.  
  84.         USE <database> INDEX <whatever>
  85.         REPORT FORM xxxxx HEADING CHR(27) + CHR(75) + "THIS HEADING;
  86.           SHOULD BE PRINTING IN BOLD" + CHR(27) + CHR(77) TO PRINT
  87.  
  88. While for most Epson's the statement would be:
  89.  
  90.         USE <database> INDEX <whatever>
  91.         REPORT FORM xxxxx HEADING CHR(27) + CHR(69) + "THIS HEADING;
  92.           SHOULD BE PRINTING IN BOLD" + CHR(27) + CHR(70) TO PRINT
  93.  
  94. The printer control codes inserted just before the information in quota-
  95. tions that will be printed as the optional heading instruct the printer to
  96. turn ON the bold or emphasized print.  The printer control codes immediate-
  97. ly after the information in quotations instructs the printer to turn OFF
  98. the bold print.  Therefore, the body of the report will be printed in the
  99. normal print style.
  100.  
  101. dBASE and FoxBASE are supposed to center the optional heading, however,
  102. including the printer control codes sometimes skews the centering. 
  103. Therefore, you may have to juggle things a little bit by inserting a blank
  104. or space or two right after the initial heading data:
  105.  
  106.         REPORT FORM xxxxx HEADING CHR(27) + CHR(69) + "   THIS HEADING;
  107.           SHOULD BE PRINTING IN BOLD" + CHR(27) + CHR(70) TO PRINT
  108.  
  109. Your needs will depend a lot upon your particular printer.  However, it is
  110. easy enough to do a test printing to determine whether you will need the
  111. blank spaces and then insert them in your code.
  112.  
  113. Underlining is a feature many like in their reports.  For the Toshibas the
  114. dBASE statement to turn on underlining is:
  115.  
  116.     ?? CHR(27) + CHR(73)
  117.  
  118. and the following statement is used to turn underlining off:
  119.     
  120.     ?? CHR(27) + CHR(74)
  121.  
  122. Epson printers seem to work in a slightly different way.  The same decimal
  123. values are used to both turn underlining on and turn it off.  The statement
  124. is:
  125.  
  126.     ?? CHR(27) + CHR(45)
  127.  
  128. The first time most Epson printers encounter these printer control codes
  129. they turn on the underline feature.  The next time they are encountered the
  130. underline is turned off.
  131.  
  132. Using this information we could then create a printed report with the
  133. optional heading underlined and the remainder of the report printed in the
  134. normal manner:
  135.  
  136. For the Toshiba P351 and P351C printers the statements would be:
  137.  
  138.         USE <database> INDEX <whatever>
  139.         REPORT FORM xxxxx HEADING CHR(27) + CHR(73) + "THIS OPTIONAL;
  140.           HEADING SHOULD BE UNDERLINED" + CHR(27) + CHR(74) TO PRINT
  141.  
  142. and the statement for most Epson printers would be:
  143.  
  144.         USE <database> INDEX <whatever>
  145.         REPORT FORM xxxxx HEADING CHR(27) + CHR(45) + "THIS OPTIONAL;
  146.           HEADING SHOULD BE UNDERLINED" + CHR(27) + CHR(45) TO PRINT
  147.  
  148.  
  149. We could get even fancier and have the optional heading printed out in bold
  150. or emphasized and underlined at the same time.  The Toshiba P351 and P351C
  151. statements would be:
  152.  
  153.         USE <database> INDEX <whatever>
  154.         REPORT FORM xxxxx HEADING CHR(27) + CHR(75) + CHR(27) + CHR(73);
  155.           + "THE OPTIONAL HEADING SHOULD BE IN UNDERLINED BOLD" +
  156.           CHR(27) + CHR(77) + CHR(27) + CHR(74) TO PRINT
  157.  
  158. while most Epsons would use the following code:
  159.  
  160.         USE <database> INDEX <whatever>
  161.         REPORT FORM xxxxx HEADING CHR(27) + CHR(69) + CHR(27) + CHR(45);
  162.           + "THE OPTIONAL HEADING SHOULD BE IN UNDERLINED BOLD" +
  163.           CHR(27) + CHR(70) + CHR(27) + CHR(45) TO PRINT
  164.  
  165. Of course, there are instances where you may want to change all of the
  166. print in a particular report.  A good example is use of the compressed
  167. print style for very wide reports.  In this instance you simply SET PRINT
  168. ON and send the printer control code.
  169.  
  170. The code to turn on the compressed print for the Toshiba printers, print
  171. the report, and then turn off the compressed print would look like this:
  172.     
  173.         USE <database> INDEX <whatever>
  174.         SET PRINT ON
  175.         ?? CHR(27) + CHR(91)
  176.         REPORT FORM xxxxx TO PRINT
  177.         EJECT
  178.         ?? CHR(27) + CHR(93)
  179.         SET PRINT OFF
  180.         
  181. Many printers, including most Epsons and Okidatas use the 015 value to set
  182. the compressed print on and the 018 value to set the compressed print off:
  183.  
  184.         USE <database> INDEX <whatever>
  185.         SET PRINT ON
  186.         ?? CHR(27) + CHR(15)
  187.         REPORT FORM xxxxx TO PRINT
  188.         EJECT
  189.         ?? CHR(27) + CHR(18)
  190.         SET PRINT OFF
  191.  
  192. One of the many things your dBASE manuals do not tell you is printer
  193. control codes can be inserted directly in the REPORT FORM you create.  This
  194. opens up a whole new world of possibilities for producing printed reports
  195. with an elegant appearance!  
  196.  
  197. How about a report with the column headings printed in bold and a letter-
  198. quality print style while the remainder of the report is printed in the
  199. standard draft mode?  Or a report where a person's ID number, name, ad-
  200. dress, and phone are all in one column but one specific piece of the data
  201. set is printed in bold and another underlined.  For reports that contain
  202. groupings or totals by group or subgroup the descriptions of the group or
  203. subgroup could be printed in bold and/or underlined.
  204.  
  205. We'll take a look at ways to do this next month.
  206.  
  207.