RRW (Rave Reports Wrapper)
Source: source/classes/rrw.prg
Standalone class
RRW is a wrapper class for the Rave Reports (RRW) runtime engine. It manages report execution via a control file (DBF-based report registry), generates a temporary .CNT control file, launches the RRWRUN.EXE engine as an external process, and collects execution results. Reports are defined in a control DBF (default RREPORTS.DBF) and executed by name.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cRi_Report | Character | Report name to execute |
cRi_OutFile | Character | Output file path for results |
cRi_Printer | Character | Print mode: "P"=printer, "D"=preview |
cRi_Filter | Character | Optional filter expression |
cRi_Query | Character | Query mode: "S"=silent, "?"=prompt, "O"=filter |
nRi_Copies | Numeric | Number of copies to print |
lActive | Logical | Is the report object active and ready |
cDataDirectory | Character | Data file directory |
cLibDirectory | Character | Report library directory |
cControlFile | Character | Path to the generated .CNT control file |
cOutFile | Character | Path to the .OUT results file |
aResults | Array | Execution results: { ecode, emsg, nReports, nPages, nRecNo } |
Methods
| Method | Description |
|---|---|
New( cControlFile, cReport, lQuery, lPreview, nBegPage, nEndPage, cDataDirectory, cLibDirectory, cTempDir, cOutFile ) | Initialize a report run: open the control DBF, locate the report, generate the .CNT control file |
End() | Close database areas and mark as inactive |
Print() | Execute the report via RRWRUN.EXE and collect results |
Activate() | Alias for Print() |
SetFilter( cVar ) | Set a filter expression and switch to filter query mode |
SetPrinter( cVar ) | Set the printer name in the control file |
Results() | Read the .OUT results file; returns array with error code, message, report count, page count, record number |
ShowError() | Display a message box with the execution error details |
Example: Execute a Rave Report
#include "FiveWin.ch"
function Main()
local oReport
oReport := RRW():New( "RREPORTS.DBF", "Invoice", .F., .T., 1, 99999, ;
"\data", "\reports" )
if oReport != nil
oReport:Print()
if oReport:aResults[ 1 ] != "0"
oReport:ShowError()
else
MsgInfo( "Report generated successfully" )
endif
oReport:End()
endif
return nil
Notes
- The control DBF (
RREPORTS.DBF) must contain at least aRI_REPORTfield for the report name,RI_LIBRARYfor the report library file,RI_WTITLEfor the window title, andRI_WPTRfor the printer name. - The class invokes
RRWRUN.EXE(the Rave Reports runtime) as an external process viaWaitRun(). - Results are written to a
.OUTfile in INI format and read back viaTIni. - Originally authored by Jerry Shaw (AlliedSignal Technical Services Corp.).