www.icetips.com  Icetips Utilities Documentation 5/15/2016    

Page Of Pages Template

Previous  Top  Next  


The Page of Pages class can be used with any kind of Clarion report.  It can be implemented in hand coded reports as well as in reports in applications.  Both Icetips Previewer and Icetips Utilities includes a template that makes it easy to implement on reports. 

 

As of June 2012, the Icetips Utilities also include a template to implement the Page of Pages class on your reports.  However, if you are using the Icetips Previewer we suggest that you use that template as it is specifically designed for the Previewer.

 

Template_ITUPageOfPagesControl

 

Class NameName of the ITPageOfPages class instance to use in the procedure.

 

 

This control template creates a string control that by default uses "?PPPP?" as the text of the control. 

 

PageOfPagesClass_Report

 

The "Page <<<# of" control is a page number control defined with a picture of "@pPage <<<# of p" and shows up in the report structure as:

 

         STRING(@pPage <<<# of p),AT(5625,8,865,208),PAGENO,USE(?PageCount),FONT('Arial',10,,),COLOR(0EAEAFFH)

 

The ?PPPP? control immediately to the right of the page number control is a normal string control that is used by the Page of Pages class.  This control will get the total number of pages to place into the control.  If it is dropped on by the Previewer control template, then it will be created like this in the report structure:

 

         STRING('?PPPP?'),AT(6500,17),USE(?ITPPageOfPages),LEFT,#SEQ(2),#ORIG(?ITPPageOfPages)

 

 

It it was dropped by this template the only difference is in the USE, which will be ?ITUPageOfPages instead of ?ITPPageOfPages

 

For a normal report where you want the Page Of to be the full range of the report, that is all you need to do!

 

However, if you want to control how many pages are in certain ranges, then all you need to do is call the ITPOP.SetPageOfPages at that point.  For example:

 

If PRO:ProductSKU[1] > 'F'

  If PRO:ProductSKU[1] <> Clip(Loc:LastProduct)

    Print(RPT:PageBreakDetail)

    ITPOP.SetPageOfPages

    Loc:LastProduct = PRO:ProductSKU[1]

  End

End

 

If you want to add this to a hand coded procedure or if you don't want to use the template, it is also very easy.  On the report procedure you need to add a few lines of code.

 

1.  In the Local data embed add:
 
ITPOP  ITPageOfPagesClass

 

2.  In the ThisWindow.OpenReport embed, after Parent Call, put:

 

ITPOP.Init(Report,SELF.PreviewQueue,'?PPPP?')

 

The first parameter is the report structure label, then it is the image queue used for the metafile pages.  The '?PPPP?' string in the final parameter MUST match the string on the report, i.e. the STRING('?PPPP?') 

 

3.  Immediately before the report is previewed, such as the ThisWindow.AskPreview embed, add:

 

ITPOP.SetPageOfPages

 

That's it!  If you are using the Icetips Previewer or Icetips Utilities control template, all you need to do is drop the control template on the report and you are done.

 

If you want to reset the total page number, for example if you are printing invoices that can multiple pages, you can simply call the SetPageOfPages method after printing each detail.  The class keeps track of which imagefiles it has updated and will not check any files that have already been updated.  The SetPageOfPages is very fast and you will not see much impact from this on your report performance.  Here is an example of code put into ThisWindow.TakeRecord after Parent call, to split a report up based on the first letter in the product name, if the name starts with the letter 'G' or later:

 

If PRO:ProductSKU[1] > 'F'

  If PRO:ProductSKU[1] <> Clip(Loc:LastProduct)

    Print(RPT:PageBreakDetail)

    ITPOP.SetPageOfPages

    Loc:LastProduct = PRO:ProductSKU[1]

  End

End

 

For a pure hand coded report, something like this should work:

 

PQ  Queue(PreviewQueue)

   END

R   REPORT,AT(1000,1000),PREVIEW(PQ),PAPER(PAPER:LETTER),THOUS,PRE(RPT)

       HEADER,AT(1000,1000,7500,350),USE(?HEADER1)

       END

detail1 DETAIL,AT(0,0,8500,217),USE(?DETAIL1)

       END

       FOOTER,AT(1000,9000,7500,275),USE(?FOOTER1)

           STRING('?PPPP?'),AT(6217,25),USE(?STRING1)

       END

   END

ITPOP  ITPageOfPagesClass  

CODE

Open(Report)

ITPOP.Init(Report,PQ,'?PPPP?')

SET(SomeFile)

Loop

   Next(SomeFile)

   If ErrorCode()

     BREAK

   END

   PRINT(RPT:Detail)

End

ITPOP.SetPageOfPages

Close(Report)

 

Is it possible that this will fail if the metafile happens to have the same string in it as you use in your INIT method?  Yes, it is possible.  However with a string like ?PPPP? it is very unlikely that you will ever run into problems with it.  To prevent possible problems with changing the token, it is only replaced if it is only found once and only once in the metafile.  So if the search string combination is found twice, then the search token will not be update with the total page count. 



Direct link to this page: http://www.icetips.com/manuals/utilities/page_of_pages_template.htm