Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

matrix report layout

Status
Not open for further replies.

mynani

MIS
Mar 20, 2002
4
US
Hi,

Does anyone have any suggestions or sample codes on how to create a matrix report using 4gl?

Such as:
1 2 3 total
A # # # ##
B # # # ##
C # # # ##

Thanks
D




 
Hi:

You might like to try a 4GL array.

This is a quick and dirty solution: Informix 4GL supports printing global arrays within a report. This example also has no error checking whatsoever, i.e. non-numeric checks, overrunning array boundaries, etc.

Let me know if you have any questions or comments.

Regards,

Ed

globals
define
tot_arr array[3,5] of record
value char(3)
end record

end globals

main
define xtot smallint,
ytot smallint,
avalue, y, x smallint

# build an array, notice the char-to-numeric conversion
let tot_arr[1,1].value ="A"
let tot_arr[1,2].value ="7"
let tot_arr[1,3].value = 8
let tot_arr[1,4].value = 9

let tot_arr[2,1].value ="B"
let tot_arr[2,2].value ="10"
let tot_arr[2,3].value = 11
let tot_arr[2,4].value = 12

let tot_arr[3,1].value ="C"
let tot_arr[3,2].value ="13"
let tot_arr[3,3].value = 14
let tot_arr[3,4].value = 15

# how many elements
let xtot = 3
let ytot = 5

# total the last column
for x = 1 to xtot
let avalue=0
for y = 2 to (ytot-1)
let avalue = avalue + tot_arr[x,y].value
if y = (ytot-1)
then
let tot_arr[x,ytot].value = avalue
end if
end for
end for

start report report1 to "./tmp.rep"
output to report report1(xtot, ytot)
finish report report1

end main

report report1(xtot, ytot)
define xtot, ytot, x, y smallint

format

first page header
print column 1, " 1 2 3 TOT"
print

on every row
for x = 1 to xtot
for y = 1 to ytot
if(y mod 5) = 0
then
print tot_arr[x,y].value # need a CR
else
print tot_arr[x,y].value; # no CR
end if
end for
end for


end report
 
Hi Ed,

Thanks for your reply. I added array to the 4gl and it works.

Thanks Again,
D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top