Re: Changing Report OUTPUT parameters at run time (how do you do it?)
Posted in 1994
>From: reetz@ncar.ucar.edu (Mike Reetz) >Subject: Changing Report OUTPUT parameters at run time (how do you do it?) >Date: 10 Oct 1994 14:55:46 GMT >X-Informix-List-Id: <news.9179> > >How do you handle changing the report OUTPUT parameters at runtime (PAGE >LENGTH, TOP MARGIN, BOTTOM MARGIN, etc.)? What I'd like to be able to do >is to pass it a page length/width into a subroutine and then be able to >calculate a reasonable PAGE LENGTH, and MARGINs. This ought to be covered in the FAQ (Kerry, please note). There is not yet any Informix-supported way to dynamically size reports in Informix-4GL. I understand NewEra does allow global variables to be used in the OUTPUT section of a report, but someone with access to NewEra manuals would need to confirm that. However, there is an alternative solution which is, I believe, in the FTP archives at rmy.emory.edu, but which I attach again just in case it isn't. I developed the c-code version; Marlin Prowell took what I'd produced, did some detective work and adapted it to work with the p-code runners. The major deficiency of the solution is that you cannot change the top margin on the first page of the report. The attached shell archive contains a manual page as well as the necessary code. Despite the disclaimer at the bottom of the manual page, there is no version of I4GL where the code would break that I know of. That, however, cannot be construed as saying it will definitely always work everywhere -- for example, I have not tested it on any 64-bit machines, and I'd not be surprised to find that the padding in the p-code report structure changed size on 64-bit machines. 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