Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : REPOBJ.ZIP
Filename : TESTREP.PRG

 
Output of file : TESTREP.PRG contained in archive : REPOBJ.ZIP
// No error checking here ... just quick and dirty!


function test()
local cOldColor := setcolor( "W+/B" )
local aStruc
local oCol1, oCol2, oCol3, oCol4, oCol5, oCol6, oCol7, oReport, nCnt
field NAME
cls
aStruc := { ;
{ "NAME", "C", 30, 0 } , ;
{ "ADDRESS", "C", 30, 0 } , ;
{ "CITY", "C", 30, 0 } , ;
{ "STATE", "C", 2, 0 } ;
}


dbcreate( "testrep1.dbf", aStruc )

aStruc := { ;
{ "NAME", "C", 30, 0 } , ;
{ "DATE", "D", 8, 0 } , ;
{ "AMOUNT", "N", 8, 2 } , ;
{ "DESCRIP", "C", 60, 0 } ;
}

dbcreate( "testrep2.dbf", aStruc )

use testrep1 exclusive alias MASTER
use testrep2 exclusive alias DETAIL NEW
index on name to testrep2

MASTER -> ( dbAppend() )
MASTER -> NAME := "JOE SOMEONE"
MASTER -> ADDRESS := "123 any street"
MASTER -> CITY := "Some large name city!!!"
MASTER -> STATE := "az"

MASTER -> ( dbAppend() )
MASTER -> NAME := "JANE SOMEONE"
MASTER -> ADDRESS := "123 notice it's capitalized"
MASTER -> CITY := "some city"
MASTER -> STATE := "Ay"

MASTER -> ( dbAppend() )
MASTER -> NAME := "Jon Credit"
MASTER -> ADDRESS := "50 B Paisley Lane"
MASTER -> CITY := "Columbia"
MASTER -> STATE := "SC"


DETAIL -> ( dbAppend() )
DETAIL -> NAME := "JOE SOMEONE"
DETAIL -> DATE := CTOD( "01/01/94")
DETAIL -> AMOUNT := 100.00
DETAIL -> DESCRIP := "This is the first purchase for Joe Someone"

DETAIL -> ( dbAppend() )
DETAIL -> NAME := "JOE SOMEONE"
DETAIL -> DATE := CTOD( "02/01/94")
DETAIL -> AMOUNT := 200.00
DETAIL -> DESCRIP := "This is the second purchase for Joe Someone"

DETAIL -> ( dbAppend() )
DETAIL -> NAME := "JOE SOMEONE"
DETAIL -> DATE := CTOD( "03/03/94")
DETAIL -> AMOUNT := 330.00
DETAIL -> DESCRIP := "This is the third purchase for Joe Someone"

DETAIL -> ( dbAppend() )
DETAIL -> NAME := "JANE SOMEONE"
DETAIL -> DATE := CTOD( "01/01/92")
DETAIL -> AMOUNT := 500.00
DETAIL -> DESCRIP := "This is the first purchase for Jane Someone"

DETAIL -> ( dbAppend() )
DETAIL -> NAME := "JANE SOMEONE"
DETAIL -> DATE := CTOD( "02/01/92")
DETAIL -> AMOUNT := 700.00
DETAIL -> DESCRIP := "This is the second purchase for Jane Someone"

DETAIL -> ( dbAppend() )
DETAIL -> NAME := "Jon Credit"
DETAIL -> DATE := date()
DETAIL -> AMOUNT := 30
DETAIL -> DESCRIP := "Just Thirty Dollars to register this report class!!"


// cTitle, bBlock, lWrap , nWidth, cPicture
oCol1 := repColumn():new("THIS IS;THE NAME", fieldwblock("NAME", select( "MASTER" ) ), .T. , 13 , NIL )
oCol2 := repColumn():new("THIS IS;THE;ADDRESS", fieldwblock("ADDRESS", select( "MASTER" ) ), .T. , 10 , "@!" )
oCol3 := repColumn():new("THIS;IS;THE;CITY", fieldwblock("CITY", select( "MASTER" ) ), .T. , 10 , "@!" )
oCol4 := repColumn():new("STATE", fieldwblock("STATE", select( "MASTER" ) ), NIL , 5 , "@!" )
oCol5 := repColumn():new("DATE OF;PURCHASE", fieldwblock("DATE", select( "DETAIL" ) ), NIL , 8 ,NIL )
oCol6 := repColumn():new("THIS IS ;A;CENTERED;TITLE!;;AMOUNT", fieldwblock("AMOUNT", select( "DETAIL" ) ), NIL , 9 , '$99999.99' )
oCol7 := repColumn():new("DESCRIPTION", fieldwblock("DESCRIP", select( "DETAIL" ) ), .T. , 15 , NIL )


oCol1:cColumnTrim := "L" // LTRIM()
oCol2:cColumnTrim := "R" // RTRIM()
oCol3:cColumnTrim := "R" // RTRIM()
oCol7:cColumnTrim := "R" // RTRIM()
oCOl6:cJustify := "C" // CENTER THE TITLE FOR COL6
oCOl7:cJustify := "C" // CENTER THE TITLE FOR COL6

oReport := report():new( {|oRepOBj| MyHeader( oRepObj ) }, {|oRepObj| MyFooter( oRepObj ) }, NIL )

oReport:addColumn( oCol1 )
oReport:addColumn( oCol2 )
oReport:addColumn( oCol3 )
oReport:addColumn( oCol4 )
oReport:addColumn( oCol5 )
oReport:addColumn( oCol6 )
oReport:addColumn( oCol7 )

oReport:lUndTitles := .T.
oReport:cWorkArea := "MASTER"
/* UNCOMMENT THIS IF YOU WANT A GRID
THE GRID WILL LOOK LIKE IT IS SPACED WHEN OUTPUT TO A FILE
HOWEVER IT PRINTS FINE TO PAPER.
THE BOTTOM AND TOP OF THE GRID ARE BEING PRINTED ON THE SAME ROW.

oReport:lGrid := .T.
oReport:lForm := .T.
*/

//
// // Lets create a child column process while the name is the same
// // we will not display the NAME. ADDRESS, or LONG DESCRIPTION while
// // in the child process!!

oCol1:lChild := .T.
oCol1:bToDo := {|| DETAIL -> ( dbseek( MASTER -> NAME ) ) }
oCol1:bWhile := {|| DETAIL -> NAME == MASTER -> NAME }
oCol1:aToBlank := { 1, 2, 3, 4 } // NAME, ADDRESS, CITY, STATE
oCol1:cChildAlias := "DETAIL"

// NOTE: if you are not doing a child relationship then you need to tell
// oCOl5 how to find its data....
// however not all of the details records will be displayed!!!

// oCol5:bFind := {|| DETAIL -> ( dbseek( MASTER -> NAME ) ) }

//
//
//
/*
Notice that we are currently at EOF() yet the report object will gotop()
by default!!
*/

SET PRINTER TO "REPORT.TXT" // DELETE THIS TO SEND TO PRINTER
SET DEVICE TO PRINT
oReport:exec()
SET DEVICE TO SCREEN
CLOSE ALL
setcolor( cOldCOlor )
CLS
?? "The report has been sent to 'REPORT.TXT' "
return (NIL)


// This function is the default value for most of the code blocks
// within the report class!!
FUNCTION NOTHING()
RETURN (NIL)

function MyHeader( oRepObj )
oRepObj:nRow := 3
@ oRepObj:nRow, 30 SAY "THIS IS A TEST REPORT"
oRepObj:nRow := 6
return (NIL)

function MyFooter( oRepObj )
oRepObj:nRow := oRepObj:nRow + 1
@ oRepObj:nRow, 25 SAY "THIS IS THE TEST REPORT FOOTER!!!!"
return (NIL)


/* You can also process a child relationship within a single database file by
using a getset function. Set the field name that is to be repeated in the child
bToDo block ... bToDo := {|| GetSetNameVar( FIELD_NAME ) }
assign bWhile to ... {|| FIELD_NAME == GetSetNameVar() }.
This will process as a child relationship until the
*/

// Standard GetSet function
function GetSetNameVar( cVar )
local cRetVar
static cName := ""
cRetVar := cName
if !( cVar == NIL )
cName := cVar
endif
return ( cRetVar )




  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : REPOBJ.ZIP
Filename : TESTREP.PRG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/