News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CatchySoft reports

Started by donkey, January 28, 2008, 07:36:51 PM

Previous topic - Next topic

donkey

While I was surfing around looking for a good (read cheap) report generator I found this CatchySoft one that caught my eye, mainly because it was not GNU and there were no distribution limitations and (most importantly) no royalties. The author says it requires ActiveX capable languages but that is not the case, simple COM is more than enough to use the library. I have decided that it is not exactly what I need however here is some code that will make it work for you if you have a need for something like this...

http://www.catchysoft.com/report_generator.html


Note: requires my CoInvoke macro
GUID_IReport equ <0xc5e6ec94,0xe00a,0x4f32,0xb8,0x61,0xcd,0x49,0xb4,0xc8,0x23,0xa5>

Dispatch STRUCT
GetTypeInfoCount DD
GetTypeInfo DD
GetIDsOfNames DD
Invoke DD
ENDS

Unknown STRUCT
   QueryInterface DD
   AddRef DD
   Release DD
ENDS

IReport STRUCT
IUnknown Unknown <>
IDispatch Dispatch <>
Print DD
PrintPreview DD
get_ReportName DD
put_ReportName DD
put_ColumnName DD
put_ColumnWidth DD
put_FieldText DD
raw_InitReport DD
Summary DD
ENDS

DATA SECTION
IID_IReport GUID GUID_IReport
psr DD ?
clsid GUID <>

CODE SECTION

Start:
// Start up COM
invoke CoInitialize,0
// Get our Class ID
invoke CLSIDFromProgID,L"CatchysoftReport.Report", offset clsid
// Create an instance for this report
invoke CoCreateInstance,offset clsid, NULL, CLSCTX_ALL,offset IID_IReport, offset psr
test eax,eax
jnz >>.NOINSTANCE

CoInvoke(psr,IReport.raw_InitReport)
test eax,eax
jnz >>.NOINIT

// Give our report a title
CoInvoke(psr,IReport.put_ReportName,L"This is a test")

// Be sure to put the Column names before width
CoInvoke(psr,IReport.put_ColumnName,L"Header 1")
CoInvoke(psr,IReport.put_ColumnName,L"Header 2")
CoInvoke(psr,IReport.put_ColumnName,L"Header 3")
CoInvoke(psr,IReport.put_ColumnName,L"Header 4")

// ColumnWidth is a percentage of the total width
CoInvoke(psr,IReport.put_ColumnWidth,25)
CoInvoke(psr,IReport.put_ColumnWidth,25)
CoInvoke(psr,IReport.put_ColumnWidth,25)
CoInvoke(psr,IReport.put_ColumnWidth,25)

xor ebx,ebx
:
// Data in a loop
CoInvoke(psr,IReport.put_FieldText,L"This is column 1")
CoInvoke(psr,IReport.put_FieldText,L"This is column 2")
CoInvoke(psr,IReport.put_FieldText,L"This is column 3")
CoInvoke(psr,IReport.put_FieldText,L"This is column 4")
inc ebx
cmp ebx,20
jne <

// Print a summary line at the end of the report
CoInvoke(psr,IReport.Summary,L"")
CoInvoke(psr,IReport.Summary,L"")
CoInvoke(psr,IReport.Summary,L"Total 1")
CoInvoke(psr,IReport.Summary,L"Total 2")

// IReport.Print does not seem to work reliably so preview
// User can print from the preview window
CoInvoke(psr,IReport.PrintPreview)

.NOINIT
// Release the interface when done
CoInvoke(psr,IReport.IUnknown.Release)

.NOINSTANCE
invoke ExitProcess,0


The library requires unicode strings, which are simple enough in GoAsm. The preview is quite nice but I could not get IReport.Print to function reliably so I decided to preview and print from the preview window which works quite well.

Have fun...

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

For those without my CoInvoke macro here it is...

CoInvoke(%pInterface,%Method,%0,%1,%2,%3,%4,%5,%6,%7,%8,%9) MACRO
#IF ARGCOUNT = 12
push %9
#ENDIF
#IF ARGCOUNT > 10
push %8
#ENDIF
#IF ARGCOUNT > 9
push %7
#ENDIF
#IF ARGCOUNT > 8
push %6
#ENDIF
#IF ARGCOUNT > 7
push %5
#ENDIF
#IF ARGCOUNT > 6
push %4
#ENDIF
#IF ARGCOUNT > 5
push %3
#ENDIF
#IF ARGCOUNT > 4
push %2
#ENDIF
#IF ARGCOUNT > 3
push %1
#ENDIF
#IF ARGCOUNT > 2
push %0
#ENDIF
push [%pInterface]
mov eax, [%pInterface]
mov eax,[eax]
add eax, %Method
call [eax]
ENDM


Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

I got an email from the author of CatchySoft and he asked me to write an example in GoAsm for his pro version, I did a translation of the C version included with the package and emailed it back, at his discretion it will be included with the distribution of his commercially available package. Perhaps a small bit of advertising for GoAsm. This is what was included, as usual, you must use my header files, the CoInvoke macro, and in this case the hello.xml file from the CatchySoft ReportGeneratorPro distribution...

http://www.catchysoft.com/report_generator_pro.html

The pro package is a retail package but it is much more powerful than the freeware version, I have had a chance to use the limited demo version and it definitely meets my needs for reports in my current project. :U

GUID_IID_IReportPro equ <0x14D21506,0x9437,0x433A,0x99,0x7C,0xD8,0x44,0xFB,0x96,0x08,0x91>

IReportPro STRUCT
IUnknown Unknown <>
IDispatch Dispatch <>
Print DD
PrintPreview DD
ReportName DD
ColumnName DD
ColumnWidth DD
FieldText DD
InitReport DD
Summary DD
InitFileName DD
BeginChildRecords DD
EndChildRecords DD
PrintVB DD
ENDS

DATA SECTION
IID_IReportPro GUID GUID_IID_IReportPro
psr DD ?
clsid GUID <>

CODE SECTION
Start:
// Start up COM
invoke CoInitialize,0
// Get our Class ID
invoke CLSIDFromProgID,L"CatchysoftReportPro.Report", offset clsid
// Create an instance for this report
invoke CoCreateInstance,offset clsid, NULL, CLSCTX_ALL,offset IID_IReportPro, offset psr
test eax,eax
jnz >>.NOINSTANCE

CoInvoke(psr,IReportPro.InitReport)
test eax,eax
jnz >>.NOINIT

// Identify the initialization file
CoInvoke(psr,IReportPro.InitFileName,L"Hello.xml")

xor ebx,ebx
:
CoInvoke(psr,IReportPro.FieldText,L"Field 1")
CoInvoke(psr,IReportPro.FieldText,L"Field 2")
CoInvoke(psr,IReportPro.FieldText,L"Field 3")
inc ebx
cmp ebx,30
jbe <

CoInvoke(psr,IReportPro.PrintPreview)

.NOINIT
// Release the interface when done
CoInvoke(psr,IReportPro.IUnknown.Release)

.NOINSTANCE
invoke CoUninitialize
invoke ExitProcess,0


Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Howard

Hi guys

I've converted Donkey's code for the pro version into MASM32v11 - if anyone's interested I'll post it.

Howard