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

DATATypeDescription
cTitleCharacterReport title
cReportNameCharacterReport definition file name (.rpt)
cDefIniCharacterMain INI file path for report definition
aAreaInisArrayArray of area INI file definitions
aFontsArrayAll fonts with properties
aColorsArrayAll color definitions
aDBAliasArrayArray of database aliases used by areas
aDBContentArrayArray of database content records
aAreaSourceArrayArea source definitions (top, width, height, etc.)
nTopMarginNumericTop paper margin in mm
nLeftMarginNumericLeft paper margin in mm
nPageBreakNumericPage break position
nOrientationNumeric1 = Portrait, 2 = Landscape
oPrnTPrinterPrinter device object
lPreviewLogicalPreview mode flag
lShowInfoLogicalShow info message during processing

Methods

MethodDescription
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

See Also