RE: Dynamic Page Length
Posted in 1994
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
We have come up with a solution to dynamic page lengths that does not include TROFF. Our solution only works on the compiled version of 4gl(we have not tried it on RDS). The Informix pre-compiler will detect an error if you attempt a statement such as: 'page length cur_len' because variables are not allowed. However, once you successfully pass the pre-compiler, the 'C' compiler has no problem with it. So if you can change the statement between these two steps, you have a solution to the problem. To accomplish this, we set the top and bottom margin to 0(we don't change left or right margins, but they are just an extension to the same logic used for top and bottom). We set the page length to 66. we set the start report command as: 'start report r_edit to pipe "lp"' We then call a function (chuz_printer) which lists all the printers and description table for the user to pick from. This table also contains the UNIX printer name, page length, and top/bottom margins. The data for the user specified printer is stored in a static record LIKE the printer table(pd.*). A char variable (prt_dest) is created for the printer destination. The code looks like this: call chuz_printer() returning pd.* let prt_dest = "lp -d", pd.prt_name clipped, " -s" let prt_size = length(prt_dest) The Makefile performs these steps: 1) c4gl -e <prog.4gl> 2) fix_ec <prog.ec> 3) c4gl -c <prog.ec> 4) links libraries with <prog.o> to form <prog.4ge> fix_ec: sed s-"\\"lp\\", 2"-"prt_dest, prt_size"- $1 > new sed s-"plength = 66"-"plength = pd.cur_len"- new > $1 sed s-"tmargin = 0"-"tmargin = pd.top_mar"- $1 > new sed s-"bmargin = 0"-"bmargin = pd.bot_mar"- new > $1 rm new fix_ec operates on the code after the pre-compiler has been run, changing the desired statements to the destination and sizes requested by the user. Also, the printer table has a CHAR column which allows us to print ASCII sequences to the printer. Now, the user can choose the same printer in landscape (which has a different page length) or compressed mode, etc. =========================================================================== Matt Bentley Database Administrator Medicode, Inc. SLC, UT (801) 536-1124 mbentle@medicode.mhs.compuserve.com ===========================================================================