First step: open the sample-app and have a look at the GLOBAL EMBEDs
Here you find the include of the ABREPORT.INC.
include('ABREPORT.INC')ABREPORT.INC is located in your Clarion-LIBSRC-Folder. It contains several declarations of variables and classes which are used in the report.
Second step: have a look at the LOCAL EMBEDs
At the beginning we initialize our Previewer:
MyPreviewer PrintPreviewClassEverything what we will print now gets written into the MyPreviewQueue. This queue has one record per page. Each page is made as a WMF-file. Its a sort of graphics format named Windows Meta Format. While the printing is in progress the application writes the pages into a temporary file (XP: C:\Documents and Settings\[username]\local settings\Temp) with the name CLA_some_number.TMP.
Third step: the miracle begins!
Insert a new piece of source and press Ctrl-F...
You get a selection of different structures to choose from. We decide for Report (Portrait) and suddenly the report formatter apears.
You do not have to do much at this moment, just close the report formatter and do not forget to save.
This is what we receive then:
Report REPORT,AT(1000,2000,6000,7000),THOUS,PRE(RPT),FONT('Arial',10) HEADER,AT(1000,1000,6000,1000) END Detail DETAIL END FOOTER,AT(1000,9000,6000,1000) END FORM,AT(1000,1000,6000,9000) END ENDThis is not much, but a complete report! Okay, I admit it is not very useful because we do not get to see anything on the paper when it is printed. We have to populate the detailband with data.
Report REPORT,AT(1000,2000,6000,7000),THOUS,PRE(RPT),FONT('Arial',10), PREVIEW(MyPreviewQueue)(NOTE: I inserted a linebreak before PREVIEW(MyPreviewQueue) for a better readability, it has to be in one line or you have to break the line with the pipe-symbol)
STRING('Printing a Queue'),AT(302,292,5250,208),USE(?String1), TRN,CENTER,FONT('Arial',10,COLOR:Black,FONT:bold,CHARSET:ANSI)(NOTE: I inserted a linebreak before TRN for a better readability)
Detail DETAIL ENDwith
DetailLevel1 DETAIL,WITHNEXT(2) STRING(@S50),AT(300,10),USE(DQ:Textline),TRN END DetailLevel2 DETAIL,WITHNEXT(2) STRING(@S50),AT(700,10),USE(DQ:Textline,,?DQ:Textline:2),TRN ENDWe will LOOP through our DataQueue (DQ) and each time we have a record with
DQ:Level = 1we know it is the country name - so we print it in the band RPT:DetailLevel1. When its DQ:Level = 2 it is a city which we print indented - we use print RPT:DetailLevel2. (Do't forget the prefix RPT!).
If you want to prevent a pagebreak inside a country -
Countryname and some cities appear on page 1 and the following cities are orphaned on page 2 -
you put a BREAK around the two Detailbands. The break is triggered when a variable changes.
In our queue each record has DQ:Sortline in common.
break1 BREAK(DQ:Sortline) DetailLevel1 .... DetailLevel2 .... END
You can add some more detailbands to be printed at certain conditions, i. e. one detail with a horizontal line as a separator and do some nested loops, calculations, There is a lot more possible and you are not limited to just one queue. You could also print from tables.Add salt and pepper as you like....