Re: Page Line Length
Posted in 1995
M J Spuffer (spuffer@clark.net) wrote: : I'm a new kid to the the Informix world. My group is just learning about : 4gl and all it's tricks. Having lived in the Pick world for many years, : its quite and adjustment. Now for the question: How do you write one : report which will run on a lazer printer (57 print lines) or a line : printer (66 lines) without replicating the entire report section? At : first thought and IF statement around the PAGE LENGTH statement would : seem proper, but to no avail. Any ideas would be appreciated. If you can live with it, set your page length to the minimum in the OUTPUT section of the REPORT functions (PAGE LENGTH 57 in your example), and set TOP OF PAGE to control-L so that the report sends a page feed to break pages instead of the default behavior of padding blank lines to break pages (TOP OF PAGE "^L" in the OUTPUT section). This would work, although you're wasting some space on the line printers. If you can't live with the wasted space (e.g. you want the same report to run to screen (24 lines) as well as to printer (66 lines) with appropriate headers always in view, etc.), try the code below. It's a straight 4gl solution, although I can envision a c solution that would involve creating 2 or 3 seperate reports (Page Header, Page Trailer, and Body), and then calling a c-function that would know to paste the header and trailer to every n lines of body text. (sounds like an interesting weekend project - any takers?) Some duplication within control blocks is required, and with more group headers/trailers things might get sticky. ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed Principal Consultant -------------------- are mine, and do not Informix Software Inc Voice: 303-850-0210 necessarily reflect Denver Colorado USA Fax: 303-779-4025 those of my employer. ########### # INFORMIX PROFESSIONAL SERVICES ####### # ## Denver, Colorado ###### # ### ================================================== ##### # #### File: %M% SCCS: %I% %P% #### # ##### Program: varlgthrpt.4go ### # ###### Client: Example ## # ####### Author: Dennis J Pimple # ########### Date: %G% %U% # Example of how to use the same REPORT function to run to variable # page length and/or screen. # The problem is we can't use a variable in our PAGE LENGTH statement. # # The general approach we take is to set PAGE LENGTH to the maximum # possible, use TOP OF PAGE "^L" so that page breaks are sending out # a line feed instead of padding the page with blank lines, and using # variable testing to break at appropriate times. # This example prompts for a page length of 10-100 MAIN DEFINE pglgth SMALLINT # Page Length (10-100) DEFINE pl CHAR(3) # for prompt DEFINE x SMALLINT # Loop counter DEFINE y SMALLINT # Loop counter CLEAR SCREEN LET pl = NULL WHILE pl IS NULL PROMPT "What Page Length (10-100) ? " FOR pl IF pl IS NULL THEN ERROR "Enter a number between 10 and 100, or INTERRUPT to quit" LET pl = NULL END IF FOR x = 1 TO LENGTH(pl) IF pl[x] NOT MATCHES "[0123456789]" THEN ERROR "Enter a number between 10 and 100, ", "or INTERRUPT to quit" LET pl = NULL END IF END FOR LET pglgth = pl CLIPPED IF pglgth < 10 OR pglgth > 100 THEN ERROR "Enter a number between 10 and 100, or INTERRUPT to quit" LET pl = NULL END IF END WHILE START REPORT rpt_varlgth TO "rpt.out" FOR x = 1 TO 10 FOR y = 1 TO 7 OUTPUT TO REPORT rpt_varlgth(pglgth, x, y) END FOR END FOR FINISH REPORT rpt_varlgth CLEAR SCREEN DISPLAY "Report is in file rpt.out" END MAIN REPORT rpt_varlgth(pglgth, x, y) DEFINE pglgth SMALLINT # Page Length (10-100) DEFINE x SMALLINT DEFINE y SMALLINT DEFINE bm SMALLINT # Bottom Margin DEFINE pt SMALLINT # Number of lines for Page Trailer DEFINE lastln SMALLINT # Last line to print on each page: # pglgth - bm - pt # set the margins and page length to minimum, # because we'll handle it in the body of the report OUTPUT TOP MARGIN 2 BOTTOM MARGIN 0 # for my purposes, I'm going to control the LEFT MARGIN # in the PRINT statements as well, but this isn't required LEFT MARGIN 0 # set page length to maximum PAGE LENGTH 100 # set TOP OF PAGE so that linefeeds are imbedded instead of blank # lines to fill out the page TOP OF PAGE "^L" # we're going to break by group on x, so inform the report that # x is already sorted. ORDER EXTERNAL BY x FORMAT PAGE HEADER IF PAGENO = 1 THEN # use this control block to initialize variables # set the bottom margin LET bm = 2 # set the number of lines in your page trailer LET pt = 2 # calculate the page line we're going to print the body # of the report on LET lastln = pglgth - bm - pt END IF PRINT "PAGE HEADER OF REPORT: ", TODAY USING "mm/dd/yyyy" SKIP 1 LINE BEFORE GROUP OF x # a lot of the code in BEFORE GROUP OF and AFTER GROUP OF are cloned # from the ON EVERY ROW. This is a pain, but necessary. We can't just # CALL functions for the duplicate code, because a PRINT statement has # to be in the REPORT function itself. # make sure we have room for the group header # + at least 1 line of data + 2 lines for group trailer IF LINENO > (lastln - 1 - 2) THEN # close off this page WHILE LINENO < lastln PRINT "" END WHILE # print the page trailer PRINT "" PRINT " - ", PAGENO USING "<&", " -" SKIP TO TOP OF PAGE END IF # print the group header PRINT "GROUP HEADER: ", x USING "#&" PRINT "----------------" ON EVERY ROW # do we have room to print this line, as well as any necessary # 2-line group trailer? IF LINENO > lastln - 3 THEN # close off this page # let the user know this group continues next page PRINT "(cont)" # close off this page WHILE LINENO < lastln PRINT "" END WHILE # print the page trailer PRINT "" PRINT " - ", PAGENO USING "<&", " -" SKIP TO TOP OF PAGE END IF # if we're at the top of a page ... IF LINENO < 5 THEN # print the (continued) group header PRINT "GROUP HEADER: ", x USING "#&", " (cont)" PRINT "-----------------------" END IF PRINT "Line ", y USING "#&", " (LINENO ", LINENO USING "<<&", ")"@@