home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / CONTRIB / MBASE / MBASE50.TAR / mbase / dox / report.dox < prev    next >
Encoding:
Text File  |  1992-10-28  |  3.6 KB  |  89 lines

  1. Report Documentation                                              MetalBase 5.0
  2. -------------------------------------------------------------------------------
  3.  
  4. Special thanks to Bruce Momjian (root%candle.uucp@ls.com) for his input, and
  5. for the inspiration for this utility.  This whole this is basically a
  6. glorified spin-off of report.c as he sent it to me when he got MB 4.0.
  7.  
  8.                                   Function
  9.  
  10. Report does just that; it produces reports on data found in relations, based
  11. on a format decided by the user in a report template.  These templates are
  12. expected to have .rpt extensions and are accessed in their native form,
  13. without any pre-compilation.
  14.  
  15. Currently, report does not allow joins; thus, each report may only access
  16. one relation's data.  However, note that in the templates, fields may be
  17. refered to either by "fieldname" or "relation.fieldname"; when further
  18. functionality is added, the latter will become necessary if a fieldname is
  19. used twice in different relations.
  20.  
  21.                               Template Format
  22.  
  23. The templates are processed "on the fly", and output is produced on the
  24. standard output, for redirection to a file, viewer, or printer as
  25. appropriate.  Output is performed in 3 stages (repeating as necessary), and
  26. the template makes use of this; an example (note that spacing is rather
  27. irrelevant--"data test.rel;" is equivalent to what you see below):
  28.  
  29.    Data
  30.       test.rel;
  31.    Size
  32.       Columns      80; # 80-column page, regardless of margins
  33.       Rows         66; # 66-row page (standard pagesize)
  34.       Top Margin    4; # 4 lines for a top margin        [you don't have to
  35.       Left Margin   8; # 8 spaces for a left margin       include any of this
  36.       Bottom Margin 2; # 2 lines for a bottom margin      you don't want--they
  37.       Right Margin  3; # 3 spaces for a bottom margin     all have defaults]
  38.  
  39.    Page 5;  # Make the first page, page number 5.  Why?  Have no idea.  :)
  40.  
  41.    Header
  42.       print centered  : "test -- ages under 30";
  43.       print centered  : system        # This just gives me some credits. :)
  44.       skip 1 line
  45.       print continued : system!date format 1, system!time format 1;
  46.       print right     : "Page: ", system!page;
  47.    Continue
  48.       print centered  : "-Continued-";
  49.    On ix_age < 30
  50.       print           : name to 40, age, hobby;
  51.  
  52.    Header
  53.       print centered  : "test -- ages over 30";
  54.       print centered  : system
  55.       skip 1 line
  56.       print continued : system!date format 1, system!time format 1;
  57.       print right     : "Page: ", system!page;
  58.    On ix_age >= 30
  59.       print           : name to 40, age, hobby;
  60.    Last
  61.       print centered  : "---";
  62.       print centered  : "Average age of all : ", age!rpt_avg;
  63.  
  64. Note that Last and Footer sections should have the same number of lines; else,
  65. the Last section will be assumed to have the same # as the Footer section, and
  66. you may end up with slightly skewed paper-alignment.  Hey--it's shareware.
  67.  
  68. The "On" line indicates that the following instructions (between "On" and
  69. the next keyword; in this case, "Last") should be executed for each record
  70. where the first field referenced by ix_age (age, in this case) is greater than
  71. or equal to thirty; thus, the following operation like the following is
  72. performed:
  73.  
  74.    for ( mb_sel (rel, idxnum(rel,"ix_age"), &rec, GTEQ, &[30]) ;
  75.          mb_errno == MB_OKAY;
  76.          mb_sel (rel, idxnum(rel,"ix_age"), &rec, NEXT, NULL) )
  77.       {
  78.         print  : name to 40, age, hobby;
  79.       }
  80.  
  81. Well, that's basically it.  Right now, the "age!rpt_avg" won't work--I
  82. haven't written it.  But, if there's enough demand...
  83.  
  84. Good luck.
  85.  
  86. PS--If your relation is encrypted, say with the key "test", try:
  87.    report -k test sample
  88.  
  89.