Page 1 of 5

Clipper Report Class

Posted: Sun Feb 26, 2017 5:09 pm
by Anand
Long, long years ago, I developed programs in Clipper.
The Clipper book by Rick Spence helped me a lot in understanding Class Inheritance, Detached Block etc.
I found the website The Oasis by Phil Barnett that had thousands if not millions of Clipper programs source codes ranging from simple date calculation to full fledged application. I learnt lot of different technique from the source codes from this site. I think many programmers here will recognize the above.

The Oasis website gave me source of CLass(y) by Anton van Straaten, after it became freeware, and many programs which used Class(y). One of them was Report Class by Jon Credit. It is pure Clipper code using Class(y) to generate tabular reports. The plus point of this class was to have the report columns defined by their width only. Column positions was auto calculated. It is some what similar to GridPrint by Rathinagiri Sir.

After I found Harbour and HMG, I learnt a lot, from the given samples, to make old Clipper codes useful again in Windows 32 bit environment. I wandered through the old forgotten Clipper codes and I stumbled on Report Class.

First I tried to compile it in Harbour and found that just by changing "Class(y)" to "hbclass.ch" it compiled and ran successfully in DOS (CMD) window.

I felt the thirst. I wanted to use this Report Class in a way that output can be Text (which it already does), PDF, HTML and XLS. Also I could have it in HMG Preview.

I want to upload the original Report Class here so that other members check it out. And also to upload my changes, after completion, for HMG so that others can also use it and make it more useful.

Now it is OK to upload it as samples for HMG ? The original Clipper code is by Jon Credit and I have made changes for HMG.
Is this correct thread of the Forum to post ?
One more query. Between MiniPrint and HbPrint, I prefer HbPrint (or WinPrint) as it already have +/- keys for zoom in preview, otherwise I found both nearly same in output. I found that there are replies on winprint in the forum but the HMG installation do not have WinPrint.ch file, whereas the MiniGui_Extended had the samples on it.
So I compiled my changes in MiniGUI_EX. Will it be problem to upload the same here at HMG ?
Please advise.

Regards,

Anand

Re: Clipper Report Class

Posted: Sun Feb 26, 2017 5:53 pm
by Rathinagiri
Anand,

Half of your story looks like mine. :) As you have said, it might be for many.

In HMG we don't have MiniPrint or HbPrint.

IMHO, you can share whatever way you want. For me, if you share the code, it might be very much useful.

Re: Clipper Report Class

Posted: Sun Feb 26, 2017 8:00 pm
by mol
+1

Re: Clipper Report Class

Posted: Sun Feb 26, 2017 8:52 pm
by serge_girard
Thanks, Anand !

Familiar story of old Clipper-days !

Serge

Re: Clipper Report Class

Posted: Mon Feb 27, 2017 4:56 am
by bpd2000
+1

Re: Clipper Report Class

Posted: Mon Feb 27, 2017 1:47 pm
by esgici
...
In HMG we don't have MiniPrint ...
...
:?:

Re: Clipper Report Class

Posted: Mon Feb 27, 2017 6:21 pm
by Anand
Thanks for the advise :)

I will post the original source of Report Class and also the changed source for HMG. I am still working on it.

Regards,

Anand

Re: Clipper Report Class

Posted: Mon Feb 27, 2017 6:26 pm
by Rathinagiri
esgici wrote: Mon Feb 27, 2017 1:47 pm
...
In HMG we don't have MiniPrint ...
...
:?:
It is not in that name, I mean.

Re: Clipper Report Class

Posted: Fri Mar 10, 2017 5:06 pm
by Anand
What I liked about the report class is the beauty of auto calculating column positions based on their widths.
One can also swap columns easily in the code. So was wondering to convert in HMG.

I studied the codes and found that the output was done by two functions only, namely, DEVPOS() and DEVOUT or DEVOUTPICT(). So I planned to make these functions such that they will give required different output, i.e. Text, Xls, Html etc. and also HMG Preview.

I created new functions gDEVPOST(), gDEVOUT() etc. and redirected the Report class to them. That's all.

The original report class does all the processing and the output comes as required.

Since I do not get enough time due to my project work pressure, I found that this enhancement for HMG was getting delayed. So I thought to upload it in the Forum and let other members to see and comment. I am sure you will find many better way to accomplish what I have envisioned and I will be happy to see this report class to become more useful by the members contribution.

I will suggest to first check the original code in Harbour. By changing "class(y).ch" to "hbclass.ch" it will compile fine and give the required output text file.

Now check my code enhancement, specially gdevposout.prg, which has all different output re-directions.

There are still issues with header printing and PDF run throwing error, though output is perfect.

Output to XML and CSV is still not done. I will try to complete them in meantime. And yes, this one compiles under MiniGUI , as I could not fix the errors generated in HMG compile, so HMG compile will also need to be done.

Attached files are:
REPOBJ.ZIP = The original report class in Clipper by Jon Credit, downloaded from The Oasis of Phil Barnett.
Report_Class1.zip = The added enhancement for HMG with extra codes.
images = of different output from the same report code.

sample part of the code is as below, for creating the report. Please note that THIS IS the original code of Clipper given as sample by Jon Credit and still useful in HMG for different output.

Code: Select all

	gDevice(cDevice, lProportionate)

	oCol1 := repColumn():new("THIS IS;THE NAME", fieldwblock("NAME", select( "MASTER" ) ), .T. , 13    , NIL )
	oCol2 := repColumn():new("THIS IS;THE;ADDRESS", fieldwblock("ADDRESS", select( "MASTER" ) ), .T. , 10    , "@!" )
	oCol3 := repColumn():new("THIS;IS;THE;CITY", fieldwblock("CITY", select( "MASTER" ) ), .T.  , 10   , "@!" )
<snip>
	oCol1:cColumnTrim := "L"                      // LTRIM()
	oCol2:cColumnTrim := "R"                      // RTRIM()
	oCol3:cColumnTrim := "R"                      // RTRIM()
<snip>

	oReport := report():new( {|oRepOBj| MyHeader( oRepObj ) },  {|oRepObj| MyFooter( oRepObj ) }, NIL )

	oReport:addColumn( oCol1 )
	oReport:addColumn( oCol2 )
	oReport:addColumn( oCol3 )
<snip>

	oReport:cWorkArea := "MASTER"

	oReport:exec()
Regards,

Anand

Re: Clipper Report Class

Posted: Fri Mar 10, 2017 8:21 pm
by EduardoLuis
Hi Anand:

Thanks for your knowledge and thanks for share with us.-
Very usefull.- I'll test it next saturday.-
Thanks, again.
Eduardo