Re: Handling changing page lengths / 4GL reports
Posted in 1992
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
Okay. For those of you who are way behind in updates, here's my rather extensive method of printing to laser printers: reports.4gl: { The technique here is to control the page format with variables. Since the OUTPUT section cannot use variables it is necessary to force the parameters of the OUTPUT section to the minimum. Then, a string containing the sub-header is created and will be printed without trailing line feed, but all necessary line feeds will be imbedded in the string. To track the number of lines actually printed a counter is used. This counter signals the printing of the sub-header when needed. Since REPORT issues line feeds to advance the paper this won't work well with laser printers. Therefore, form feeds are printed to advance the paper as needed for use with laser printers. This works well for any kind of printer. } DATABASE hrdwrlog REPORT hrdwr_report(rpt_rec, rpt_sel) DEFINE <stuff deleted> i INTEGER, lf CHAR(1), ff CHAR(1), num_lines INTEGER, top_mar INTEGER, bot_mar INTEGER, lft_mar INTEGER, pag_len INTEGER, title CHAR(50), p_desc CHAR(40), s_desc CHAR(40), page_no INTEGER, first_time INTEGER, sub_head CHAR(1000) OUTPUT TOP MARGIN 0 BOTTOM MARGIN 0 LEFT MARGIN 0 PAGE LENGTH 1 FORMAT FIRST PAGE HEADER { Initialize variables } LET ff = ASCII 12 LET lf = ASCII 10 LET page_no = 1 LET first_time = 0 { Set quasi OUTPUT parameters } IF rpt_sel.rpt_to = "P" THEN { Printer } LET top_mar = 1 LET bot_mar = 1 LET lft_mar = 10 LET pag_len = 60 ELSE LET top_mar = 0 LET bot_mar = 0 LET lft_mar = 0 LET pag_len = 60 END IF { Print main header } LET title = NULL FOR i=1 TO top_mar LET title = title CLIPPED, lf END FOR PRINT title CLIPPED; LET num_lines = top_mar + 16 LET title="HARDWARE LOG FAILURES" PRINT lft_mar + 29 - LENGTH(title)/2 SPACES, title CLIPPED, lf; <stuff deleted - you get the idea> "=================================================================", lf; ON EVERY ROW IF (num_lines + bot_mar + 3) > pag_len THEN LET page_no = page_no + 1 LET sub_head = NULL FOR i=1 TO top_mar LET sub_head = sub_head CLIPPED, lf END FOR LET sub_head = sub_head CLIPPED, lft_mar SPACES, "HARDWARE LOG FAILURES", <stuff deleted> "=================================================================", lf PRINT ff, sub_head CLIPPED; LET num_lines = top_mar + 7 END IF <stuff deleted> ON LAST ROW IF (num_lines + bot_mar + 3) > pag_len THEN LET page_no = page_no + 1 LET sub_head = NULL FOR i=1 TO top_mar LET sub_head = sub_head CLIPPED, lf END FOR LET sub_head = sub_head CLIPPED, lft_mar SPACES, "HARDWARE LOG FAILURES", <stuff deleted> "=================================================================", lf PRINT ff, sub_head CLIPPED; LET num_lines = top_mar + 6 END IF PRINT lf PRINT "TOTAL PROBLEMS: ", COUNT(*) USING "####" END REPORT ------------------------------------------------------------------------------ John R. Carter, Sr. Programmer/Analyst - Informix DBA Computer Sciences Corporation jcarter@nas.nasa.gov Numerical Aerodynamic Simulation 415/604-3662 NASA Ames Research Center, Moffett Field, CA 94035-1000 M/S 258-6 ------------------------------------------------------------------------------