Re: Dynamic page lengths in reports
Posted in 1994
>From: alan@dssmktg.com (Alan Goodman) >Subject: Dynamic page lengths in reports >Date: Sat, 16 Apr 94 00:38:28 GMT >X-Informix-List-Id: <news.6338> > >Greetings people, > >We write reports for our customers that must be able to handle being >printed on various and sundry printers with different page lengths and >orientations. > >We don't know which printer,page length, or orientation will be selected >until runtime when the user selects a printer for output. > ... >What we really would like is some dynamic way of telling informix the page >length of a report at runtime. Then we could take advantage of all the >cool reporting functions like page header and page trailer, etc. >(Informix, are you listening? This would be a REALLY nice enhancement!!!!) > >Thanks for listening (reading). Does anyone else have really cool ways of >handling this problem? I entered an FR (feature request) for this in 1989, before I even worked for Informix. 4GL++ will support this properly (well, mostly properly; you'll be able to do it without hacking at the language, anyway). In the meantime, here's some code I put together which works for compiled I4GL, and some code which works with RDS assembled by Marlin Prowell taking some hints from the compiled version. The only snag is that you don't get the page size set until you execute code in the PAGE HEADER or FIRST PAGE HEADER block, and that's a fraction too late for adjusting the TOP MARGIN on the first page. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> : "@(#)shar.sh 1.8" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Fri Jul 24 11:43:14 GMT 1992 by johnl at Informix Software Ltd. # Files archived in this archive: # report.man # report.c # rejig.4gl # #-------------------- if [ -f report.man -a "$1" != "-c" ] then echo shar: report.man already exists else echo 'x - report.man (4043 characters)' sed -e 's/^X//' >report.man <<'SHAR-EOF' X'\\" @(#)report.man 1.4 92/07/24 X'\\" @(#)Manual page: General Library -- Report Configuration X.ds fC "report.man 1.4 92/07/24 X.TH REPORT 3S "JLSS Informix Tools" X.SH NAME Xset_output \\(em Dynamically reconfigure dimensions of I4GL report X.SH SYNOPSIS X.ft B Xfunction set_plength(i) X.br Xdefine i integer X.sp Xfunction set_tmargin(i) X.br Xdefine i integer X.sp Xfunction set_bmargin(i) X.br Xdefine i integer X.sp Xfunction set_lmargin(i) X.br Xdefine i integer X.sp Xfunction set_rmargin(i) X.br Xdefine i integer X.sp Xfunction set_output() X.ft R X.ft B Xfunction get_plength() X.sp Xfunction get_tmargin() X.sp Xfunction get_bmargin() X.sp Xfunction get_lmargin() X.sp Xfunction get_rmargin() X.ft R X.SH DESCRIPTION XThese functions can be used to dynamically reconfigure the layout Xof the page of an Informix 4GL report. XThe example program shown below illustrates how they should be used. X.br X.ft CW X.ps 10 X.vs 12 X.nf X.so rejig.4gl X.br X.fi X.ft X.ps X.vs XThe functions \\fIset_plength\\fP, \\fIset_tmargin\\fP, X\\fIset_bmargin\\fP, \\fIset_lmargin\\fP and \\fIset_rmargin\\fP may be called Xanywhere inside an I4GL program. XThe function \\fIset_output\\fP will have no effect except within a report. XIt is recommended that \\fIset_output\\fP be used in the \\s-2FIRST XPAGE HEADER\\s0 control block, but it may be used in any control block. X.P XAfter the function \\fIset_output\\fP is called, it invalidates all the settings; Xto change the settings in a second report, you must call the Xset-routines again. XThere is no requirement that all the routines are called (or even any of them). X.P XThe functions \\fIget_plength\\fP, \\fIget_tmargin\\fP, X\\fIget_bmargin\\fP, \\fIget_lmargin\\fP and \\fIget_rmargin\\fP may be called Xanywhere inside an I4GL program. XIf page dimensions have been set using the set-routines, then the corresponding Xvalue is returned; otherwise, the corresponding default value is returned. XAfter \\fIset_output\\fP has been called, the values returned will be Xthe default values again; if your report needs to know what its dimensions will Xbe, it should use the get-routines before calling \\fIset_output\\fP. X.SH COMPILATION XIf compiling for use with compiled Informix-4GL, no special flags are needed. XIf compiling for use with I4GL-RDS, include -DI4GL_RDS on the command line. XThe details of building the functions into the \\*Cfglgo\\*D Xand \\*Cfgldb\\*D are given in the corresponding Informix manuals. XThe necessary definitions for \\*cfgiusr.c\\*d are: X.br X.ft CW X.ps 10 X.vs 12 X.nf X#ifdef SET_REPORT Xextern int set_output(); /* 0 */ Xextern int get_rmargin(); /* 0 */ Xextern int get_tmargin(); /* 0 */ Xextern int get_bmargin(); /* 0 */ Xextern int get_lmargin(); /* 0 */ Xextern int get_plength(); /* 0 */ Xextern int set_rmargin(); /* 1 */ Xextern int set_tmargin(); /* 1 */ Xextern int set_bmargin(); /* 1 */ Xextern int set_lmargin(); /* 1 */ Xextern int set_plength(); /* 1 */ X#endif /* SET_REPORT */ X X#ifdef SET_REPORT X { "set_output", set_output, 0 }, X { "get_rmargin", get_rmargin, 0 }, X { "get_tmargin", get_tmargin, 0 }, X { "get_bmargin", get_bmargin, 0 }, X { "get_lmargin", get_lmargin, 0 }, X { "get_plength", get_plength, 0 }, X { "set_rmargin", set_rmargin, 1 }, X { "set_tmargin", set_tmargin, 1 }, X { "set_bmargin", set_bmargin, 1 }, X { "set_lmargin", set_lmargin, 1 }, X { "set_plength", set_plength, 1 }, X#endif /* SET_REPORT */ X.br X.fi X.ft X.ps X.vs X.SH WARNINGS XThis code was designed and tested on an ATT&T 3B2/400 running XUNIX System V Release 3.0 using Informix-4GL version 1.10.00C. XIt has since been tested on a number of other environments (including Versions X1.10.03, 4.00 and 4.10) on a number of platforms, and has been found to work. XHowever, the code cannot be guaranteed on any platform or version of I4GL. XIt is completely unsupported code. X.SH BUGS XThe top margin set by \\fBset_tmargin\\fP does not take effect Xuntil the second page of output. X.SH AUTHOR XJonathan Leffler X.br XMarlin Prowell X.br XJLSS X.br X24th July 1992 SHAR-EOF chmod 444 report.man if [ `wc -c <report.man` -ne 4043 ] then echo shar: report.man unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f report.c -a "$1" != "-c" ] then echo shar: report.c already exists else echo 'x - report.c (7529 characters)' sed -e 's/^X//' >report.c <<'SHAR-EOF' X/* X@(#) File: report.c X@(#) Vers