VRD - Visual Report Designer Engine
Source: source/classes/vrd.prg
Standalone class (report engine)
VRD is the runtime engine for the Visual Report Designer. It loads and processes report
definitions stored in .rpt (INI-format) files, manages data areas, processes database
queries, and drives the printing or previewing of complex reports. It is not a visual
designer itself but the execution engine that reads the output of the designer.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cTitle | Character | Report title |
cReportName | Character | Report definition file name (.rpt) |
cDefIni | Character | Main INI file path for report definition |
aAreaInis | Array | Array of area INI file definitions |
aFonts | Array | All fonts with properties |
aColors | Array | All color definitions |
aDBAlias | Array | Array of database aliases used by areas |
aDBContent | Array | Array of database content records |
aAreaSource | Array | Area source definitions (top, width, height, etc.) |
nTopMargin | Numeric | Top paper margin in mm |
nLeftMargin | Numeric | Left paper margin in mm |
nPageBreak | Numeric | Page break position |
nOrientation | Numeric | 1 = Portrait, 2 = Landscape |
oPrn | TPrinter | Printer device object |
lPreview | Logical | Preview mode flag |
lShowInfo | Logical | Show info message during processing |
Methods
| Method | Description |
|---|---|
New( cReportName, lPreview, cPrinter, oWnd, lModal, lPrintIDs, lNoPrint, lNoExpr, cAreaPath, lPrintDialog, nCopies, lCheck, oPrint, aSize, cTitle, cPreviewDir, lAutoBreak, lShowInfo ) | Create VRD engine and load report definition |
End( lPrintArea ) | Close report, release resources, optionally print |
AreaStart( nArea, lPrintArea, aIDs, aStrings, lPageBreak ) | Start processing a report area |
AreaStart2( nArea, lPrintArea, aIDs, aStrings, lPageBreak ) | Alternate area start with extended parameters |
PrintArea( nArea, nAddtoTop, lPageBreak ) | Print all items in a report area |
PrintRest( nArea, nAddtoTop, lPageBreak ) | Print remaining space in an area after items |
PrintItem( nArea, nItemID, cValue, nAddToTop, lMemo, nEntry ) | Print a specific item in an area |
PrintItemList( nArea, aIDs, aStrings, nAddToTop ) | Print a list of items by ID |
GetItem( nArea, nItemID ) | Get item definition data from area INI |
DrawBox( nTop, nLeft, nBottom, nRight ) | Draw a rectangle box on the report |
Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad ) | Print text at specified position |
SayMemo( nTop, nLeft, nWidth, nHeight, cText, oFont, nColor, nPad, lVariHeight ) | Print memo text with word wrap |
OpenDatabases() | Open all databases referenced by report areas |
CloseDatabases() | Close all opened databases |
GetDBContent( cDatabase, cDBAlias, cDBType, cSeparator, nIndex ) | Retrieve database content for an area |
DBSum( cDatabase, cField, nLen, nDec, cFor, lPrevious, lCount ) | Compute sum of a database field |
DBCount( cDatabase, cFor ) | Count records matching a condition |
SetExpression( cName, cExpression, cInfo ) | Define a named expression for use in items |
GetExpression( cName ) | Retrieve a named expression value |
EvalExpression( cText ) | Evaluate a Harbour expression in report context |
PageBreak( lPrintArea ) | Insert a page break |
PrintDialog() | Show print setup dialog with printer, copies, range |
SetPaperSize( aSize ) | Set custom paper dimensions |
Example: Load and Preview a Report
#include "FiveWin.ch"
function Main()
local oRpt
// Load a report definition and open in preview mode
oRpt := VRD():New( "C:\reports\invoice.rpt", .T. )
oRpt:OpenDatabases()
oRpt:AreaStart( 1 )
oRpt:PrintArea( 1 )
oRpt:End()
return nil
Notes
- VRD reads report definitions from INI-format
.rptfiles created by the Visual Report Designer application. These files define areas, items, fonts, colors, database connections, and expressions. - Report areas are logical sections (e.g., page header, detail, page footer). Each area has its own set of items (text, fields, lines, boxes) positioned at design-time coordinates.
- The engine supports calculated expressions, database summaries, conditional printing, and page break management.
- Multiple databases can be opened simultaneously via
aDBAlias, supporting master-detail report structures.