INFORMIX-4GL Dynamic Report Output Parameters Version 2
Posted in 1992
Some time ago, I lobbed some C code at the net which adapted the output dimensions of an I4GL report at runtime, with the comment that I hadn't got it to work with I4GL-RDS. On 29th April 1992, Marlin Prowell put an adapted version of my code on to the net, having made it work under I4GL-RDS. The shell archive below is an integrated version of our two efforts: there is a compile line parameter -DI4GL_RDS required to make it work under I4GL-RDS and no parameter for compiled I4GL (I4GL-C?). There is also an updated manual page, and some example I4GL code which is used in the manual page. I hope you find this useful. Marlin: thanks for the effort -- it was a great help. And for the fix in the code. I've kept your comments in the code. Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h> FYI: I didn't cheat and look at the source code for the Informix products. : "@(#)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@(#) Version: 2.1 X@(#) Last changed: 92/07/24 X@(#) Purpose: I4GL: Reset report output parameters (RDS & C4GL) X@(#) Author: J Leffler / M Prowell X*/ X X/*TABSTOP=4*/ X X/* X** INFORMIX-4GL Dynamic Report Output Parameters Version 2 X** C4GL code (and interface) by J Leffler. X** RDS interface by M Prowell. X** X** Compilation: X** C4GL: cc -c report.c X** RDS: cc -c -DI4GL_RDS report.c X*/ X X/* X** Addendum to Marlin's comments. X** -- tested on SUNOS 4.1.1 and I4GL-RDS 4.10.UC1 and it seems to work X** correctly, but it is still unsupported code. X*/ X X/* X** From: uunet!nys