home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / rptform.zip / REPORT2 < prev    next >
Text File  |  1987-02-01  |  11KB  |  310 lines

  1.                    REPORT FORM - THE dBASE REPORT GENERATOR
  2.                    ========================================
  3.  
  4.                                     Part 2 
  5.  
  6.  
  7.  
  8.  
  9.  
  10. Last month we reviewed how to define the contents of a column in REPORT
  11. FORM (among other things).  This month, let's begin by examining other
  12. aspects of defining columns in a report such as the column widths and
  13. column headings.
  14.  
  15.  
  16.  
  17.  
  18. REPORT FORM COLUMN WIDTHS
  19. =========================
  20.  
  21. The column width for each REPORT FORM column or field defaults to the
  22. combined width of all items placed within the field/column - even when ";"
  23. is used to create multiple data lines within the column.  This can be
  24. overridden by simply typing in the desired width of the column in the box
  25. presented for each field.
  26.  
  27. When the field or column width is set to less than the width of the
  28. contents (assuming no ";" has been used), REPORT FORM will wrap the
  29. remainder of the contents to the next line.  dBASE tries very hard to place
  30. the data within the column so information in character strings is not
  31. split, except where blanks occur.  If dBASE can not find any handy blanks
  32. between concatenated strings, some data may end up on a lower line.  If
  33. this happens simply MODIFY STRUCTURE by placing a SPACE() between data
  34. fields at the wrap point:
  35.  
  36.  
  37.         FIELD1 + SPACE(1) + FIELD(2)
  38.  
  39.  
  40. When the report is printed the SPACE() or blank field will be "lost". 
  41. However, the SPACE() is reflected in the default REPORT FORM field width
  42. count.
  43.  
  44. Be particularly careful about column width settings when MODIFYing REPORT. 
  45. If there are columns in your REPORT FORM where you have set the width to
  46. less than the dBASE default width, making changes in that column will
  47. return the width to the dBASE default.  It is necessary to again override
  48. the dBASE default by specifying the column width.
  49.  
  50. This nasty little bug has been present since release 1.0 dBASE III and has
  51. carried through all the way to release 1.1 of dBASE III PLUS.  Apparently
  52. Ashton-Tate does not see it as a real problem, but if you make good use of
  53. REPORT FORM and MODIFY REPORT it can become a serious difficulty.
  54.  
  55.  
  56.  
  57.  
  58.  
  59. COLUMN/FIELD HEADINGS
  60. =====================
  61.  
  62. dBASE views all column or field headings as character strings.  Memory
  63. variables can NOT be used in the column headings, nor can macros.
  64.  
  65. When the character string for the column heading is wider than the contents
  66. of the column, REPORT FORM automatically adjusts the column width to the
  67. width of the column heading.  However, you can override this by choosing
  68. the column width option and setting your own column width.
  69.  
  70. In this case, when the column heading is wider than the specified width of
  71. the column, dBASE will wrap the heading and print it on more than one line.
  72. Thus, in addition to the four column heading lines provided by the REPORT
  73. FORM, dBASE can be tricked into providing additional lines of column/field
  74. headings.
  75.  
  76. Column or field headings for columns which contain character type data are
  77. automatically left justified by dBASE.
  78.  
  79. The Report Generator automatically right justifies column (field) headings
  80. for numeric fields when the report is printed.  This can be changed by
  81. converting the numeric fields to character fields with the STR() function
  82. when creating your report:
  83.  
  84.         STR(NUMFIELD)
  85.  
  86.  
  87. In this case dBASE will treat the numeric field as a character field. 
  88. Remember, however, you may have to adjust for the decimal places - and the
  89. ability to subtotal and total numbers will be eliminated.
  90.  
  91.  
  92.  
  93.  
  94.  
  95. SPACE() With REPORT FORM
  96. ========================
  97.  
  98. Because the report generator left justifies data and headings in character
  99. columns/fields and right justifies numeric data, the two spaces dBASE
  100. automatically places between columns often do not provide enough room
  101. between columns for a good looking report.  SPACE() can be used to insert a
  102. column in between to obtain that better appearance.  Simply enter the
  103. SPACE() statement with the desired number of spaces in its own field
  104. contents box.  The following would provide a blank column of five spaces
  105. between data columns:
  106.  
  107.         SPACE(5)
  108.  
  109.  
  110. SPACE() can also be used to force the wrap-around feature of the column
  111. headings and provide more than the allotted four heading lines in the Field
  112. header box:
  113.  
  114.     Field       1.  DEPARTMENT + SPACE(20) + DATE HIRED
  115.      header     2.  SPACE(2) + TITLE
  116.                 3.  SPACE(3) + SALARY
  117.                 4.  SPACE(4) + PHONE
  118.  
  119.  
  120. would produce a print-out of the field or column header this way:
  121.  
  122.             DEPARTMENT
  123.              DATE HIRED
  124.               TITLE
  125.                SALARY
  126.                 PHONE
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. GROUP TOTAL AND SUBTOTAL HEADINGS
  135. =================================
  136.  
  137. When using totals and subtotals in a report, dBASE begins listing data
  138. immediately after the heading description for groupings and subgroupings. 
  139. Having a blank line between the group or subtotal headings (and the
  140. subgroup/subtotal headings) and the data under each heading makes a much
  141. nicer looking report.  
  142.  
  143. The manuals don't mention that this can be done, but it is possible. 
  144. Because dBASE will wrap any group heading longer than the width of the
  145. report, you can trick REPORT FORM into giving you this nice appearance by
  146. using the SPACE() function.
  147.  
  148. First of all, make sure your printer is set for wrap-around printing.  How
  149. to accomplish this varies with the different makes and models of printers
  150. and, therefore, can not be addressed here.  You will need to refer to your
  151. printer manual. 
  152.  
  153. In REPORT FORM, include the statement 
  154.  
  155.         SPACE(n) + "." 
  156.  
  157.  
  158. after the statements of the data field(s) upon which the report form will
  159. be grouped or subtotaled:
  160.  
  161.         DEPT + SPACE(75) + "."
  162.  
  163.  
  164. Placing this type of a statement in the "Group heading" or "Sub-group
  165. heading" boxes has no effect since, in the actual report, the information
  166. is displayed as:
  167.  
  168.         * <Group Heading>: <Group Expression>
  169.  
  170.         ** <Sub-Group Heading>: <Sub-Group Expression>
  171.  
  172.  
  173. The actual length of the space would depend upon whether you are using 80
  174. or 132 column paper and the length of the data field(s) upon which you are
  175. grouping or subtotaling.
  176.  
  177. Although dBASE will "wrap" to give you a blank line, it does not increase
  178. it's line counter with the wrap.  Therefore, you will need to adjust the
  179. number of lines per page accordingly.  I usually change the lines per page
  180. option from the default of 58 lines per page to 56 per page.  However, if
  181. you anticipate having many different groupings on each page this would have
  182. to be decreased even further.
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190. OPTIONAL PAGE HEADINGS FOR REPORTS
  191. ==================================
  192.  
  193. There are so many different types of headings possible in REPORT FORM that
  194. it can really become confusing.  This section refers to headings which are
  195. not created in the REPORT FORM itself but, rather, by using the HEADING
  196. option statement when issuing the command which will initiate the report:
  197.  
  198.         REPORT FORM xxxx HEADING xxxx NOEJECT TO PRINT
  199.  
  200.  
  201.  
  202. The HEADING statement must be a character expression.  Numeric, Date, and
  203. Logical types are not accepted.  Any combination of memory variables, data
  204. fields (including aliases), and functions is acceptable as long as all data
  205. types are character.
  206.  
  207. Therefore, it is necessary to convert dates to character strings with the
  208. DTOC() function and to change numeric information to character strings with
  209. the STR() function.  As an example, to include the current date in an
  210. optional heading, the following statements would be required:
  211.  
  212.         STORE DTOC(DATE()) TO CDAY
  213.         REPORT FORM xxxxxx HEADING "AS OF " + CDAY
  214.  
  215.                   or
  216.  
  217.         REPORT FORM xxxxxx HEADING "AS OF " + DTOC(DATE())
  218.  
  219.           
  220.  
  221. As you might gather from the above example, REPORT FORM can use variable
  222. data without macro substitution.  As an example, create a memvar called
  223. TITLE:
  224.  
  225.         TITLE = "Test Heading Option"
  226.  
  227.  
  228. and print the report using the following statement:
  229.  
  230.  
  231.         REPORT FORM xxxx HEADING TITLE NOEJECT TO PRINT
  232.  
  233.     
  234. And you will see a title line saying "Test Heading Option" appear above the
  235. header lines included in the REPORT FORM itself.
  236.  
  237. Using a field from the database in use in the HEADING option provides a
  238. wide range of possibilities.  When the data field is included the informa-
  239. tion from the field in the record to which the pointer is directed will be
  240. printed or displayed. (dBASE then goes to the top of the file to begin the
  241. report.)
  242.  
  243. Assume, for instance, you have a database which is a master list of
  244. patients (PATIENT) and another database which is a record of visits made
  245. (VISIT).  You want to generate a report listing all visits made to a
  246. particular patient, with the patient's name printed at the top of the
  247. report.  However, the VISIT database records do not contain the patient's
  248. name, just the patient's ID number.  So we must first go to the PATIENT
  249. database to find the patient and his/her ID number:
  250.  
  251.  
  252.         SELECT 1
  253.         USE PATIENT INDEX PNAME
  254.         SELECT 2
  255.         USE VISIT INDEX VDATE
  256.         STORE SPACE(20) TO MEMFIRST, MEMLAST
  257.         * ----------------------------------------------------------
  258.         *  User enters name of patient
  259.         * ----------------------------------------------------------
  260.         CLEAR
  261.         @ 2,5 SAY "Enter patient's first name: " GET MEMFIRST PICTURE "@A!"
  262.         READ
  263.         @ 4,5 SAY "Enter patient's last name: "  GET MEMLAST PICTURE "@A!"
  264.         READ
  265.         SELECT PATIENT
  266.         STORE MEMFIRST + MEMLAST TO LOOKUP
  267.         SEEK LOOKUP
  268.         * ----------------------------------------------------------
  269.         *  Patient record located
  270.         * ----------------------------------------------------------
  271.         SELECT VISIT
  272.         REPORT FORM VREPORT HEADING TRIM(PATIENT->FNAME) + ;
  273.          " " +  PATIENT->LNAME FOR IDNO = PATIENT->IDNO
  274.         * ----------------------------------------------------------
  275.         *  Visit report generated
  276.         * ----------------------------------------------------------
  277.         RETURN
  278.  
  279.  
  280.  
  281.  
  282. The Ashton-Tate manuals lead one to believe that only one optional heading
  283. line is available.  However, it is possible to trick dBASE into supplying
  284. multiple line optional headings.  This is because the optional heading will
  285. wrap around at 40 columns or characters.  
  286.  
  287.  
  288. While the 40 column wrap may present a problem for some, it can be used
  289. effectively to obtain multiple line optional headings by including the
  290. SPACE() option in your headings:
  291.     
  292.  
  293.     REPORT FORM xxxx  HEADING "EXAMPLE UNIVERSITY" + SPACE(32) 
  294.        + "Department of Physics"
  295.  
  296.  
  297.  
  298.  
  299. The semi-colon (without quotes) can also be used to obtain multiple line
  300. optional headings:
  301.  
  302.  
  303.       REPORT FORM xxxx HEADING "EXAMPLE " ; + "Department of Physics"
  304.  
  305.  
  306.  
  307. The HEADING option and the PLAIN option can NOT be used together.  The
  308. PLAIN option cancels the HEADING option, so your optional heading would not
  309. appear on the report.
  310.