home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / REPTOOLS.ZIP / HOWTO.TXT next >
Encoding:
Text File  |  1996-09-07  |  29.8 KB  |  896 lines

  1.   
  2.                       THE FiveWin REPORT ENGINE HOW-TO GUIDE
  3.   
  4.     Quick FiveWin Printing Techniques:
  5.  
  6.        Besides the sophisticated FiveWin Report Engine, FiveWin offers 
  7.     you RAD (Rapid Application Development) techniques to quickly
  8.     prototype your printouts:
  9.  
  10.     * Generating a full report from the current workarea:
  11.  
  12.       Just call the function Report() to get a complete paged report 
  13.       automatically generated from the current workarea.
  14.  
  15.     * Generating an automatic report from any browse:
  16.  
  17.       If you do <oBrw>:Report() where <oBrw> is a reference to your
  18.       browse, FiveWin will generate a full report with the same
  19.       contents as your browse.  So the easiest way to implement a
  20.       report in your browse is to place a bitmap button on your 
  21.       DialogBox with the action <oBrw>:Report().
  22.  
  23.     * Making a printer HardCopy of any Window or control:
  24.  
  25.       If you have a Dialog and you want to obtain a printout of it,
  26.       the easiest way is just doing: <oDlg>:HardCopy( nZoom ) where
  27.       <oDlg> is your Dialog object and <nZoom> is a scale factor -
  28.       a value of 3 is normally recommended to obtain natural dimensions
  29.       You can use a bitmap instead of a Dialog, window or control.
  30.  
  31.     * Re-use pre-existing Clipper DOS reports almost as-is. See REPT23.PRG.
  32.  
  33.        Combining these techniques, you can very quickly prototype your
  34.     first application printouts. Don't forget them!
  35.  
  36.        Remember to use these techniques in the first stages of your
  37.     application development.
  38.      
  39.     SAMPLE REPORTS DEMONSTRATE HOW
  40.  
  41.        Included in the \SAMPLES\REPORT subdirectory are over 20 .PRGs
  42.     that demonstrate how to use the Report Engine.  An explanation
  43.     follows of what each .PRG demonstrates....
  44.   
  45.     ------------------------
  46.     REP01.PRG
  47.   
  48.     A VERY SIMPLE REPORT:
  49.   
  50.     All the reports have the following construction:
  51.   
  52.     LOCAL oReport
  53.     
  54.     REPORT oReport ...
  55.     COLUMN ...
  56.     COLUMN ...
  57.     END REPORT
  58.     
  59.     ACTIVATE REPORT oReport ...
  60.     
  61.     As you can see the basic construction is very simple. Here is the
  62.     complete syntax with all the optional bells and whistles:
  63.  
  64.     REPORT [ <oReport> ] ;
  65.         [ TITLE <bTitle, ...> [< LEFT | CENTER | CENTERED | RIGHT > ] ];
  66.         [ HEADER <bHead, ...> [< LEFT | CENTER | CENTERED | RIGHT > ] ];
  67.         [ FOOTER <bFoot, ...> [< LEFT | CENTER | CENTERED | RIGHT > ] ];
  68.         [ FONT <oFont, ...> ]  ;
  69.         [ PEN <oPen, ...> ]  ;
  70.         [ < lSum:SUMMARY >  ] ;
  71.         [ < file: FILE |  FILENAME |  DISK >  <cRptFile> ] ;
  72.         [ < resource: NAME |  RESNAME | RESOURCE >  <cResName> ] ;
  73.         [ < toPrint: TO PRINTER >  ] ;
  74.         [ < toScreen: PREVIEW >  ] ;
  75.         [ TO FILE <toFile> ] ;
  76.         [ TO DEVICE <oDevice> ] ;
  77.         [ CAPTION <cName> ]
  78.  
  79.     GROUP [ <oRptGrp> ] ;
  80.        [ ON <bGroup> ] ;
  81.        [ HEADER <bHead> ] ;
  82.        [ FOOTER <bFoot> ] ;
  83.        [ FONT <uFont> ] ;
  84.        [ < lEject:EJECT >  ]
  85.  
  86.     COLUMN [ <oRptCol> ] ;
  87.         [ TITLE <bTitle, ...> ] ;
  88.         [ AT <nCol> ] ;
  89.         [ DATA <bData, ...> ] ;
  90.         [ SIZE <nSize> ] ;
  91.         [ PICTURE <cPicture, ...> ] ;
  92.         [ FONT <uFont> ] ;
  93.         [ < total: TOTAL >  [ FOR <bTotalExpr> ] ] ;
  94.         [ < ColFmt:LEFT | CENTER | CENTERED | RIGHT >  ] ;
  95.         [ < lShadow:SHADOW >  ] ;
  96.         [ < lGrid:GRID >  [ <nPen> ] ]
  97.  
  98.     ENDREPORT
  99.  
  100.     ACTIVATE REPORT <oReport> ;
  101.        [ FOR <for> ] ;
  102.        [ WHILE <while> ] ;
  103.        [ ON INIT <uInit> ] ;
  104.        [ ON END <uEnd> ] ;
  105.        [ ON STARTPAGE <uStartPage> ] ;
  106.        [ ON ENDPAGE <uEndPage> ] ;
  107.        [ ON STARTGROUP <uStartGroup> ] ;
  108.        [ ON ENDGROUP <uEndGroup> ] ;
  109.        [ ON STARTLINE <uStartLine> ] ;
  110.        [ ON ENDLINE <uEndLine> ] ;
  111.        [ ON CHANGE <bChange> ]
  112.  
  113.     
  114.     With the command COLUMN (syntax above) you indicate all the 
  115.     columns that the report will have indicating the data and the 
  116.     title of each column. This can be very simple. For example:
  117.     
  118.     COLUMN TITLE "Name" DATA Test->Name
  119.     
  120.     ------------------------
  121.     REP02.PRG
  122.     
  123.     IMPLEMENTING TOTALS:
  124.     
  125.     If you want a Total on any column just add the word TOTAL in the 
  126.     command, for example:
  127.     
  128.     COLUMN TITLE "Salary" DATA Test->Salary TOTAL
  129.     
  130.     ------------------------
  131.     REP03.PRG
  132.     
  133.     HEADERS & FOOTERS:
  134.     
  135.     You can put any header and footer on the report by declaring them 
  136.     in the REPORT command. For example:
  137.     
  138.     REPORT oReport TITLE "My First Report" ;
  139.          HEADER "This is the header" ;
  140.          FOOTER "This is the footer"
  141.     
  142.     You can even specify how it will be written: left, centered or right, 
  143.     adding the word LEFT, RIGHT or CENTER|CENTERED. For example:
  144.     
  145.     REPORT oReport TITLE "My First Report" ;
  146.          HEADER "This is the header" RIGHT ;
  147.          FOOTER "This is the footer" CENTER
  148.     
  149.     Remember: by default Titles are centered and Headers and Footers are 
  150.     written on the left side.
  151.     
  152.     -------------------------
  153.     REP04.PRG
  154.     
  155.     MULTILINE TITLES, HEADERS AND FOOTERS:
  156.     
  157.     If you want more than one line for a title just put a comma between 
  158.     each title. For example:
  159.     
  160.     REPORT oReport ;
  161.         TITLE "My First Report", "with FiveWin"
  162.     
  163.     The same happens with headers and footers.
  164.     
  165.     The report engine NEVER puts a white line between the header and the 
  166.     title or between the title and the column titles. It is up to you to 
  167.     put the blank lines wherever you want them. For example, if you want 
  168.     to put a blank line between the header and the title, just indicate a 
  169.     second line on the header with nothing on it -- just an empty chain:
  170.     
  171.     REPORT oReport TITLE "My Report ;
  172.          HEADER "My Header", " "
  173.     
  174.     -------------------------
  175.     REP05.PRG
  176.     
  177.     USING EXPRESSIONS:
  178.     
  179.     You can put almost anything you want in your reports because you can 
  180.     use any expression that returns a character string, remember this is 
  181.     the key to do almost anything you want. For example, if you want to 
  182.     put the date() on the report plus the current page number, just 
  183.     do the following:
  184.     
  185.     REPORT oReport TITLE "My Report" ,;
  186.      "date:"+DtoC(Date())  ;
  187.           FOOTER "Page Number: "+ ;
  188.                          Str(oReport:nPage,3)
  189.     
  190.     You can put expressions rather than character strings in almost 
  191.     anywhere: Titles, Headers, footers, Column titles, column data, etc...
  192.     
  193.     --------------------------
  194.     REP06.PRG
  195.     
  196.     REPORT DESTINATION:
  197.     
  198.     By default, the report is sent to the printer, but you can change it 
  199.     when you create the report:
  200.     
  201.     REPORT oReport .... ;
  202.         TO PRINTER  => (The default)
  203.     
  204.     REPORT oReport .... ;
  205.         PREVIEW  => (To Screen)
  206.     
  207.     REPORT oReport .... ;
  208.         TO FILE <cFile>  => (Txt format)
  209.     
  210.     When you send the report to the screen (PREVIEW), the report engine 
  211.     creates all the pages until you push the button Preview, and then 
  212.     you will immediately see the first page created.
  213.     
  214.     When you create a Report you can specify a caption for it. This 
  215.     caption would be the title of the preview Window if you send the 
  216.     report to the screen, or it will be the description on the spooler if 
  217.     you send it to the printer. (In previous releases we used the word 
  218.     NAME for this.)
  219.     
  220.     -------------------------------
  221.     REP07.PRG
  222.     
  223.     USING FONTS:
  224.     
  225.     You can use any font you want with your reports. This is the way you 
  226.     use them:
  227.     
  228.     First you have to define them with the command DEFINE FONT oFont ....
  229.     
  230.      DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
  231.      DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD
  232.  
  233.     The size (width,height) specs. use different units of measure when
  234.     printed versus displayed on screen.  On screen, the units are pixels,
  235.     but when printed, the units are font "points".  Thus, for printed
  236.     text, we only use the second size specification (height) to give the
  237.     point size, leaving the "width" as "0".  The point size is given as
  238.     a negative number, i.e. "10 point" is "-10".  Remember that point
  239.     size for proportionally spaced type is different than "pitch," which
  240.     is the term often used for non-proportionally spaced "typewriter" type 
  241.     like Courier.  Point size refers to letter height, whereas pitch 
  242.     refers to the number of equal-spaced letters printed per inch. Regular
  243.     "pica" sized typewriter type is 10 pitch - 10 letters per inch. But
  244.     represented in point size, this is 12 point -- very confusing because
  245.     the smaller "elite" typewriter type is 12 pitch - 12 letters per inch,
  246.     which is 9 point.  (With "pitch," the bigger the number, the smaller
  247.     the font -- just the opposite of how "point" size works.) Now to add 
  248.     to the confusion, remember that in this Report Engine, we let FiveWin 
  249.     know that we're working with point size instead of pixels by using 
  250.     negative numbers for points (and we must use points instead of pitch 
  251.     for equal-spaced fonts like Courier).  In this case, the "-" sign 
  252.     isn't mathematical -- it doesn't mean (as math rules would suggest) 
  253.     that your point size gets smaller as the integer gets bigger.  Just 
  254.     the reverse. The bigger the integer, the bigger the point size.  If 
  255.     you're still confused, there's a fellow named Guttenberg on CIS who 
  256.     can explain it all to you.
  257.  
  258.     When you create the report, you specify the fonts you want to use, 
  259.     separating each one with a comma. 
  260.  
  261.     For example:   
  262.  
  263.     REPORT oReport TITLE ..... ;
  264.          FONT oFont1, oFont2, oFont3
  265.     
  266.     The first font in the list (oFont1) will be the standard font, so if 
  267.     you do not specify a font for a specific column it will use the 
  268.     standard font (oFont1). 
  269.     
  270.     If you want a column to use the second font just do the following:
  271.     
  272.     COLUMN TITLE ... DATA .... FONT 2
  273.     
  274.     As you can see, you indicate the ordinal number in the list of fonts 
  275.     defined when you create the report.
  276.     
  277.     Again, you can use an expression this way:
  278.     
  279.     COLUMN TITLE ... DATA ... ;
  280.           FONT iff(Test->Salary>1000,2,1) 
  281.     
  282.     Remember to release the fonts after the report is done.
  283.  
  284.     Now here is the complete syntax:
  285.  
  286.     Defining a font:         DEFINE FONT <oFont> ;
  287.                                 [ NAME <cName> ] ;
  288.                                 [ SIZE <nWidth>, <nHeight> ] ;
  289.                                 [ FROM USER ];
  290.                                 [ BOLD ] ;
  291.                                 [ ITALIC ] ;
  292.                                 [ UNDERLINE ] ;
  293.                                 [ WEIGHT <nWeight> ] ;
  294.                                 [ OF <oDevice> ] ;
  295.  
  296.                                 [ NESCAPEMENT <nEscapement> ] ;
  297.  
  298.                              ACTIVATE   FONT <oFont>
  299.  
  300.                              DEACTIVATE FONT <oFont>
  301.  
  302.                              RELEASE FONT <oFont>
  303.  
  304.                              SET FONT ;
  305.                                 [ OF <oWnd> ] ;
  306.                                 [ TO <oFont> ]
  307.  
  308.  
  309.     <oFont>         A reference to the Font Object.
  310.  
  311.     <cName>         The name of the font. Example: Arial, Roman, etc...
  312.  
  313.     <nWidth>,       Dimensions of the font -- pixels for screen fonts, but
  314.     <nHeight>          points for printed fonts.  For printed fonts, use
  315.                        "0" for <nWidth> and use <nHeight> for the points with
  316.                        a minus sign in front of the points number.
  317.  
  318.     <oWnd>          A reference to the Window container.
  319.  
  320.     <oDevice>       The device owner of the font.
  321.  
  322.     <nWeight>       The weight of the font.
  323.  
  324.     <nEscapement>   The escapement of the font.
  325.  
  326.     CLAUSES
  327.  
  328.     FROM USER       Displays the Font selection Dialog Box.
  329.  
  330.     BOLD            To create the font with bold feature.
  331.  
  332.     ITALIC          To create the font with italic feature.
  333.  
  334.     UNDERLINE       To create the font with underline feature.
  335.  
  336.     
  337.     ------------------------------
  338.     REP08.PRG
  339.     
  340.     CONFIGURING COLUMNS:
  341.     
  342.     When you create the columns, you can specify a lot of behavior:
  343.     
  344.     - PICTURE: As same as GETS
  345.     - SIZE: Length of the column (number of Chars)
  346.     - AT: Print at specific column (better not use it)
  347.     - FONT: Font to use (number in the list of fonts)
  348.     - TOTAL: if the column should have a total
  349.     
  350.     If you specify that the column has a total, the DATA should be a 
  351.     number. But if not, do not worry -- the report engine does not break. 
  352.     The TOTAL clause can have also a FOR condition. For example:
  353.     
  354.     COLUMN DATA ... TOTAL FOR Test->Name = "Peter"
  355.     
  356.     - LEFT|CENTER|CENTERED|RIGHT: You can also specify the way the text is 
  357.     going to be printed, left, center or right. By default, everything is 
  358.     left formated except numeric data which is right.
  359.     
  360.     ----------------------------
  361.     REP09.PRG
  362.     
  363.     MULTILINE COLUMNS:
  364.     
  365.     This is something you will really love: suppose you need to put 
  366.     another column but you do not have enough width on the paper to do it? 
  367.     
  368.     You could use a smaller font, but this is not the best way. The best 
  369.     way is to use multi lines for columns. That means that one database 
  370.     register can use more than one line on the report. So we can do 
  371.     something like this:
  372.     
  373.     Name                Salary
  374.     =================== ===========
  375.     Test->First         Test->Salary
  376.     Test ->Last
  377.     
  378.     This is as simple as:
  379.     
  380.     COLUMN DATA Test->First, Test->Last
  381.     
  382.     Just separate with a comma the data you want to be printed.
  383.     
  384.     You can do the same with the column title, like this:
  385.     
  386.     COLUMN DATA Test->First, Test->Last ;
  387.          TITLE "First Name" ,"Last Name"
  388.     
  389.     If you put a TOTAL on that column, all the numeric data will be added. 
  390.     All the data will have the same picture, but I will explain later 
  391.     how to change this behavior.
  392.     
  393.     --------------------------
  394.     REP10.PRG
  395.     
  396.     MAKING GROUPS:
  397.     
  398.     To make a group means to have a subtotal on a particular kind of 
  399.     data. With the report form you can make two groups. With other report 
  400.     generators you can make up to 9, but with FiveWin Report Engine you 
  401.     have no limit.
  402.     
  403.     If you want the totals of the groups to be printed you must totalize 
  404.     at least one column.
  405.     
  406.     The data, of course, should be sorted in accord with the group 
  407.     expression.
  408.     
  409.     To make a Group just do the following:
  410.     
  411.     REPORT oReport ....
  412.     COLUMN ....
  413.     COLUMN ....
  414.     
  415.     GROUP ON Test->State EJECT
  416.     
  417.     END REPORT
  418.     
  419.     The report will totalize each column that has been created with the 
  420.     TOTAL clause for every State and will make a page eject when the 
  421.     State changes.
  422.     
  423.     You can even specify a Header, a Footer and a font to use for that 
  424.     group (just one line on Headers and Footers):
  425.     
  426.     GROUP ON Test->State ;
  427.          FOOTER "Total State:"  ;
  428.          FONT 2 ;
  429.          EJECT
  430.     
  431.     Remember, you can have all the groups you want.
  432.     
  433.     --------------------------
  434.     REP11.PRG
  435.     
  436.     SUMMARY REPORTS:
  437.     
  438.     If you specify the clause SUMMARY when you create the report:
  439.     
  440.     REPORT oReport TITLE ... SUMMARY
  441.     
  442.     it will only print the information about groups. So the clause 
  443.     SUMMARY should only be used when there is at least one group defined.
  444.     
  445.     When you use the SUMMARY clause the report engine does not put any 
  446.     group separator line.
  447.     
  448.     ---------------------------
  449.     REP12.PRG
  450.     
  451.     CONTROLLING THE FLOW OF THE REPORT:
  452.     
  453.     When you activate the report, it is possible to define FOR and WHILE 
  454.     conditions. For example:
  455.     
  456.     ACTIVATE REPORT oReport    ;
  457.          WHILE Test->State = "A"  ;
  458.          FOR Test->Salary > 1000
  459.     
  460.     Because the report engine can make a report even from an array, by 
  461.     default the WHILE condition is "!Eof()". So if you change the WHILE 
  462.     condition, you must take care that if you are making a report from a 
  463.     database it is a good practice to include in the WHILE condition the 
  464.     text  ".and. !Eof()":
  465.     
  466.     ACTIVATE REPORT oReport    ;
  467.          WHILE Test->State = "AZ"  .AND. !Eof() ;
  468.          FOR Test->Salary > 100000
  469.     
  470.     You can even control the flow of the report in the same manner as you 
  471.     do with other windows.
  472.     
  473.     When you activate the report you can indicate functions that will be 
  474.     called when the report is in a particular state:
  475.     
  476.     ACTIVATE REPORT oReport ;
  477.          ON INIT ... ;
  478.          ON END .... ;
  479.          ON STARTPAGE ....;
  480.          ON ENDPAGE ... ;
  481.          ON STARTGROUP .... ;
  482.          ON ENDGROUP .... ;
  483.          ON STARTLINE ... ;
  484.          ON ENDLINE .... ;
  485.          ON CHANGE ...
  486.     
  487.     The INIT function is called just one time on the first page after the 
  488.     column titles are printed.
  489.     
  490.     The END function is called just one time on the last page after the 
  491.     Grand totals are printed. 
  492.     
  493.     The STARTPAGE is called on every start of a page. This is one of the 
  494.     most used because in this clause you will put bitmaps, lines, boxes, 
  495.     etc...
  496.     
  497.     The ENDPAGE is called on every end of a page, when all the text is 
  498.     printed (not very useful).
  499.     
  500.     The STARTGROUP is called on every start of a group and before the 
  501.     header of the group is printed (if there is one).
  502.     
  503.     The ENDGROUP is called on every end of a group.
  504.     
  505.     The STARTLINE is called on every start of a line of the report body. 
  506.     When STARTLINE is evaluated, the report engine is controlling if the 
  507.     following line will fit in the current page, and if not, it will do 
  508.     an Eject and start a new page. Be carefull when using STARTLINE, 
  509.     because if you use Multiline columns there will be at least two 
  510.     STARTLINES for each record processed.
  511.     
  512.     The ENDLINE is called on every end of line of the body report. When 
  513.     ENDLINE is evaluated all the line has been printed and the current 
  514.     report line is been incremented.
  515.     
  516.     The CHANGE is called on every "SKIP" if you are listing a database. 
  517.     For practical purposes, this function is called before the SKIP and 
  518.     not after. This is also a clause you will use a lot.
  519.     
  520.     In the source code we have include a blank line on StartGroup and a 
  521.     sound beep when the report is finished.
  522.     
  523.     IMPORTANT: Be careful when using these clauses. Remember you are 
  524.     inside the report flow, so you must take care of all the databases, 
  525.     indexes, etc.. that the report is using.
  526.     
  527.     ---------------------------
  528.     REP13.PRG
  529.     
  530.     UNDERSTANDING THE REPORT OBJECT:
  531.     
  532.     You can access almost any part of the report if you understand how 
  533.     it works and how it is designed.
  534.     
  535.     The report object has a lot of data and methods that you should know 
  536.     and use.
  537.     
  538.     An object report has at least one object column, one object Line 
  539.     (for the title), one object device and if it has group(s), it will 
  540.     also have a Group object. 
  541.     
  542.     The objects TRColumn, TRLine and TRGroup are the basis of the report 
  543.     engine. 
  544.     
  545.     TRColumn holds all the columns of the report including its title, 
  546.     data, totals, etc.. (vertical object)
  547.     
  548.     TRLine holds all the lines wich go across the report from left to 
  549.     right. You can think of them as horizontal objects. These include 
  550.     Titles, Header and Footers.
  551.     
  552.     TRGroup holds all the information about each group defined in the 
  553.     report.
  554.     
  555.     You can manipulate the behavior of any object modifying its data or 
  556.     using some of its methods.
  557.     
  558.     Take a look at the classes data and methods. You will be impressed 
  559.     about all you can do. The only limit is your imagination.
  560.     
  561.     Examples:
  562.     
  563.     1) Change the TITLE font of column 3 to use the second font. Also 
  564.     because the column is multiline, change the picture of the second 
  565.     line to "999,999":
  566.     
  567.     LOCAL oColumn
  568.     
  569.     oColumn := oReport:aColumns[3]
  570.     oColumn:bTitleFont := {|| 2}     // It's a block
  571.     oColumn:aPicture[2] := "999,999"
  572.     
  573.     2) Left Justify the first line of the title using font 2 
  574.     and right justify the second line using font 3:
  575.     
  576.     #define LINE_LEFT     1
  577.     #define LINE_RIGHT   2
  578.     
  579.     LOCAL oLine
  580.     
  581.     oLine := oReport:oTitle
  582.     oLine:aPad[1]:= LINE_LEFT        // pad of line 1
  583.     oLine:aPad[2]:= LINE_RIGHT       // pad of line 2
  584.     oLine:aFont[1]:= {|| 2}          // font of line 1
  585.     oLine:aFont[2]:= {|| 3}          // font of line 2
  586.     
  587.     As you can see, the object TRLine also holds multiple lines. That way 
  588.     the DATA is mostly arrays.
  589.     
  590.     3) On the footer of each group, print the current value of it and the 
  591.     counter of how many records have been included:
  592.     
  593.     GROUP ON Test->State ;
  594.         FOOTER "Total State "+;
  595.                 oReport:aGroups[1]:cValue+ ;
  596.                      str(oReport:aGroups[1]:nCounter)
  597.     
  598.     --------------------------------
  599.     REP14.PRG
  600.     
  601.     GOING BACKWARDS:
  602.     
  603.     Just do a GO BOTTOM, change the way the Report does
  604.     the skip, and change the while condition:
  605.     
  606.     USE TEST NEW
  607.     GO BOTTOM
  608.     
  609.     REPORT oReport ....
  610.          COLUMN ...
  611.     END REPORT
  612.     
  613.     oReport:bSkip := {|| DbSkip(-1)}
  614.     
  615.     ACTIVATE oReport WHILE !Bof()
  616.     
  617.     -------------------------------
  618.     REP15.PRG
  619.     
  620.     PRINTING ARRAYS:
  621.     
  622.     Use a static variable to hold the current array element and change 
  623.     the Skip block and While block.
  624.     
  625.     STATIC  nField
  626.     
  627.     Function Main()
  628.     
  629.          nField := 1
  630.     
  631.          REPORT oReport ....
  632.          COLUMN ...  
  633.          COLUMN ...
  634.          END REPORT
  635.     
  636.          oReport:bSkip := {|| nField++}
  637.     
  638.          ACTIVATE REPORT oReport ;
  639.               WHILE nField <= len(aStructure)
  640.     
  641.     --------------------------------------
  642.     REP16.PRG
  643.     
  644.     SHADOWS & GRIDS:
  645.     
  646.     There are two clauses that you can use when you create your columns: 
  647.     
  648.     - SHADOW: This clause puts the background of a column in light gray.
  649.     
  650.     - GRID: This clause puts two lines vertically on both sides of a 
  651.       column.
  652.     
  653.     For example:
  654.     
  655.     COLUMN TITLE ... SHADOW GRID
  656.     
  657.     You can modify the type of grid, width and color. To do this you have 
  658.     to create the pens you need:
  659.     
  660.     COLUMN TITLE ... GRID <nPen>
  661.     
  662.     By default the pen used is black, solid, with a width of 1.
  663.     
  664.     The creation of pens is identical as for fonts. (Consult the Norton 
  665.     Guide for more information about pens.) For example:
  666.     
  667.     DEFINE PEN oPen WIDTH 5
  668.     
  669.     REPORT oReport PEN oPen
  670.          COLUMN TITLE .... GRID 1
  671.     END REPORT
  672.     
  673.     ACTIVATE REPORT
  674.     
  675.     -------------------------
  676.     REP17.PRG
  677.     
  678.     CHANGING THE ASPECT:
  679.     
  680.     There is some DATA on the report objects that lets you change the 
  681.     aspect of the report, for example:
  682.     
  683.     - nTotalLine: Is the aspect for total lines. By default it is 
  684.       RPT_DOUBLELINE (2)
  685.     
  686.     - nGroupLine: Is the aspect for group lines. By default it is 
  687.       RPT_SINGLELINE (1)
  688.     
  689.     - nTitleUpLine: Is the aspect for the up lines in column titles. 
  690.       By default it is RPT_DOUBLELINE (2)
  691.     
  692.     - nTitleDnLine:  Is the aspect for the down lines in column titles. 
  693.       By default it is RPT_DOUBLELINE (2)
  694.     
  695.     - cPageTotal: Is a description for page total. By default it is ""
  696.     
  697.     - cGrandTotal: Is a description for grand total. By default it is ""
  698.     
  699.     - lSpanish: If .T. all the windows and dialogs are in Spanish.
  700.     
  701.     And also some methods like:
  702.     
  703.     - Margin(nValue,nType,nScale): This method lets you change the top, 
  704.       down, left and right margin of the report -- in inches or 
  705.       centimeters.
  706.     
  707.     Say(nCol, xText, nFont, nPad, nRow): This method lets you write the 
  708.     text you want on the report, indicating the column (where the column 
  709.     objects start), the text, the number of font to use, the number of 
  710.     pad(left, right, center) and the Row (by default the current row).
  711.     
  712.     ------------------------------
  713.     REP18.PRG
  714.     
  715.     BITMAPS:
  716.     
  717.     To put a bitmap on your report is very easy. In the STARTPAGE clause, 
  718.     just make a call to a function of your own which draws the bitmap via 
  719.     the Saybitmap method() of the class TReport. An example:
  720.     
  721.     ACTIVATE REPORT oReport ;
  722.          ON STARTPAGE Mybitmap()
  723.     
  724.     Function Mybitmap()
  725.     
  726.          oReport:SayBitmap(.3,.3,"ICO.BMP",.5,.5)
  727.     
  728.     RETURN NIL
  729.     
  730.     These are the parameters of the method Saybitmap:
  731.     
  732.     1) nRow
  733.     2) nCol
  734.     3) cBitmap file (only)
  735.     4) nWidth
  736.     5) nHeight
  737.     6) nScale
  738.     
  739.     If Scale is in INCHES (1) then 1,2,4 and 5 are in inches, and if 
  740.     Scale is CMETERS (2) 1,2,4 and 5 are in centimeters.
  741.     
  742.     ------------------------------
  743.     REP19.PRG
  744.     
  745.     BOXES & LINES:
  746.     
  747.     To put a box or a line on your report is very easy. On the STARTPAGE 
  748.     clause, just make a call to a function of your own which draws the 
  749.     line or box via the box or line method() of the class TReport. An 
  750.     example:
  751.     
  752.     ACTIVATE REPORT oReport ;
  753.          ON STARTPAGE Mybox()
  754.     
  755.     Function Mybox()
  756.          oReport:Box(.1, .1, 11.1, 7.6)
  757.     RETURN NIL
  758.     
  759.     These are the parameters of the BOX method:
  760.     
  761.     1) nRow
  762.     2) nCol
  763.     3) nBottom
  764.     4) nRight
  765.     5) nPen
  766.     6) nScale
  767.     
  768.     If nScale is in INCHES (1) then 1,2,3  and 4 are in inches, and if 
  769.     nScale is CMETERS (2) 1,2,3 and 4 are in centimeters.
  770.     
  771.     The fifth parameter is the number in the list of pens stated when 
  772.     you created the report.
  773.     
  774.     These are the parameters of the LINE method:
  775.     
  776.     1) nTop
  777.     2) nLef
  778.     3) nBottom
  779.     4) nRight
  780.     5) nPen
  781.     6) nScale
  782.     
  783.     If nScale is in INCHES (1) then 1,2,3  and 4 are in inches, and if 
  784.     nScale is CMETERS (2) 1,2,3 and 4 are in centimeters.
  785.     
  786.     The fifth parameter is the number in the list of pens stated when 
  787.     you created the report.
  788.     
  789.     ---------------------------
  790.     REP20.PRG
  791.     
  792.     PRINTING MEMOS:
  793.     
  794.     Printing memos on reports is sometimes a difficult job in other 
  795.     reporting systems, but is quite easy with the FiveWin Report Engine.
  796.     
  797.     Look how we do it:
  798.     
  799.     1) Create a column with empty DATA, but indicating the size (width 
  800.     of line in chars) that you want for the memo:
  801.     
  802.         COLUMN TITLE "Comments" DATA " " SIZE 50
  803.     
  804.     2) Create a function to be called by the ON CHANGE clause, like this:
  805.     
  806.     Function SayMemo()
  807.     
  808.      LOCAL nLines, nFor
  809.      nLines := Mlcount(Test->Comment,50)
  810.      
  811.      /*
  812.      Since ON CHANGE has caused the line to be incremented, we need to 
  813.      decrement the current line once.
  814.      */
  815.     
  816.      oReport:BackLine(1)
  817.     
  818.      /*
  819.      Now we can start the printing. But remember: before we print 
  820.      anything, we have to make a call to StartLine, and also afterwards 
  821.      a call to EndLine. This way the program controls the page breaks.
  822.      */
  823.      
  824.      FOR nFor := 1 to nLines
  825.         oReport:StartLine()
  826.         oReport:Say(nMemoColumn , ;
  827.              MemoLine(Test->Comment,50,nFor)
  828.         oReport:EndLine()
  829.       NEXT 
  830.     
  831.     RETURN NIL
  832.     
  833.     And that is all there is to it.
  834.     
  835.     -------------------------------
  836.     REP21.PRG
  837.     
  838.     PUTTING IT ALL TOGETHER:
  839.     
  840.     Just take a close look at the code for REP21.PRG.
  841.     
  842.     --------------------------------
  843.     REP22.PRG
  844.     
  845.     ALL TOGETHER AND WITH COLORS!
  846.  
  847.        You can change the color of each font using the SetTxtColor method.
  848.  
  849.        SetTxtColor() receives two parameters. The first one indicates the
  850.     nColor to use (see Colors.ch) and the second one the NUMBER of the
  851.     Font in the report. For example:
  852.  
  853.                         oReport:SetTxtColor(CLR_HRED,1)
  854.  
  855.     You can also control the color of any Pens just by indicating their
  856.     colors when you create them. For example:
  857.  
  858.            DEFINE PEN oPen COLOR CLR_BLUE
  859.  
  860.     If you want to change the color of the horizontal pen used in titles
  861.     and totals, use the method SetPenColor.  For example:
  862.  
  863.                         oReport:SetPenColor(CLR_RED)
  864.  
  865.     You can also change the color of the shadows using the method
  866.     SetShdColor(nNewColor), which by default is LIGHTGRAY.
  867.  
  868.     --------------------------------
  869.     Rept23.PRG
  870.     
  871.     PRINTING FROM A .TXT FILE:
  872.     
  873.        In Rept23.PRG we are using the memo printing technique to print a 
  874.     text file.  This is very useful for quickly converting Clipper DOS 
  875.     reports to windows.  
  876.     
  877.        For example, if your DOS application has reports created via the 
  878.     R&R Code Generator or Bandit, use that DOS report's option to have 
  879.     each report sent to a .TXT file.  Then adapt the simple code in this 
  880.     example to have FiveWin print the report's .TXT file.  Make sure that 
  881.     the font specified in this code matches the font used in the creation 
  882.     of the report. Guess what this means....you can convert each of your 
  883.     existing DOS reports to windows in 20 minutes each MAX, no matter how 
  884.     intricate they may be!
  885.     
  886.          Caveat: of course, whatever user interface screen code you have 
  887.     at the beginning of your DOS report .prg (for prompts/responses to 
  888.     specify various report options) will have to be converted to 
  889.     FiveWin GUI. Still quick -- after you establish a standard and 
  890.     adaptable format for your prompts/responses.
  891.  
  892.          NOTE: When previewing this report, until you zoom out it will
  893.     appear garbled due to the use of the fixed pitch Courier font.  If
  894.     you print it, it won't be garbled.
  895.  
  896.     ---------------------------------