#include "FiveWin.ch"
#include "easyrep.ch"
// ----------------------------------------------------------------------------//
REQUEST FWHARU
FUNCTION Main()
LOCAL aStates, aCust, aRow, nAt, nStateCol
LOCAL oDlg, oBrwStates, oBrwCust, oBtn
TPrinter():lUseHaruPDF := .t.
USE STATES
aStates := FW_DbfToArray()
USE CUSTOMER
nStateCol := FieldPos( "state" )
aCust := FW_DbfToArray()
CLOSE CUSTOMER
AEval( aStates, {| a| AAdd( a, Array( 0 ) ) } )
FOR EACH aRow in aCust
nAt := AScan( aStates, {| a| a[ 1 ] == aRow[ nStateCol ] } )
IF nAt > 0
AAdd( aStates[ nAt, 3 ], aRow )
ENDIF
NEXT
DEFINE DIALOG oDlg ;
TITLE "EasyReport with Array" ;
SIZE 1000, 600 ;
PIXEL ;
TRUEPIXEL
@ 0, 0 ;
BTNBMP oBtn ;
PROMPT "EasyReport" ;
OF oDlg ;
ACTION DruckListe( aStates ) ;
COLOR CLR_WHITE, CLR_MAGENTA ;
FLAT SIZE 100, 32
@ 40, 20 XBROWSE oBrwStates SIZE 270, -20 PIXEL OF oDlg ;
DATASOURCE aStates ;
COLUMNS 1, 2 HEADERS "CODE", "NAME" ;
CELL LINES NOBORDER
WITH OBJECT oBrwStates
:bChange := {|| oBrwCust:aArrayData := oBrwStates:aRow[ 3 ], ;
oBrwCust:GoTop(), oBrwCust:Refresh() }
:CreateFromCode()
END
@ 40, 290 ;
XBROWSE oBrwCust ;
OF oDlg ;
PIXEL ;
SIZE - 20, -20 ;
DATASOURCE aStates[ 1, 3 ] ;
COLUMNS 2, 3, 5, 6 ;
HEADERS "FIRST", "LAST", "CITY", "STATE" ;
CELL ;
LINES ;
NOBORDER
WITH OBJECT oBrwCust
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RETURN NIL
// -----------------------
FUNCTION DruckListe( aStates )
LOCAL oVRD
LOCAL lPreview := .T.
LOCAL cDruckerName := ""
LOCAL cTemp := ""
LOCAL nNr := 1
LOCAL nSeite := 0
LOCAL nIdx := 0
LOCAL I := 0
LOCAL aTemp := {}
local oPrn
// ----------------------------------------------------------
TPreview():lListViewHide := .f.
EASYREPORT oVRD NAME "erep01\states.vrd" PREVIEW .t. //FILE "erep01.pdf"
PRINTAREA 1 OF oVRD ;
ITEMIDS { 101, 102 } ;
ITEMVALUES { "Report with array", DToC( Date() ) }
PRINTAREA 2 OF oVRD;
ITEMIDS { 100 } ;
ITEMVALUES { "Anyone have a sample how i can relationate 2 arrays (masterdata/detail) and pass to fastreport?" }
PRINTAREA 7 OF oVRD
FOR nIdx := 1 TO Len( aStates )
PRINTAREA 3 OF oVRD ;
ITEMIDS { 100, 101, 102 } ;
ITEMVALUES { "c:\fwh\samples\xVrd\kreis.jpg", aStates[ nIdx, 1 ], ;
aStates[ nIdx, 2 ] }
aTemp := aStates[ nIdx, 3 ]
FOR I := 1 TO Len( aTemp )
PRINTAREA 4 OF oVRD ;
ITEMIDS { 102, 103, 104, 105 } ;
ITEMVALUES { aTemp[ I, 2 ], aTemp[ I, 3 ], aTemp[ I, 4 ], aTemp[ I, 5 ] }
IF oVRD:nNextRow > oVRD:nPageBreak
nSeite := nSeite + 1
PRINTAREA 5 OF oVRD ;
ITEMIDS { 100 } ;
ITEMVALUES { AllTrim( Str( nSeite ) ) }
PAGEBREAK oVRD
PRINTAREA 6 OF oVRD
PRINTAREA 2 OF oVRD
PRINTAREA 7 OF oVRD ;
ITEMIDS { 120 } ;
ITEMVALUES { DToC( Date() ) }
ENDIF
NEXT
NEXT
oVRD:End()
RETURN NIL
// ----------------------------------------------------------------------------//