Files
harbour-core/harbour/tests/testdbf.prg
Viktor Szakats e788d6d3e8 2012-07-18 13:54 UTC+0200 Viktor Szakats (harbour syenar.net)
+ contrib/hbgt/tests
  + contrib/hbgt/tests/test.prg
  + contrib/hbmisc/tests/rtfclass.prg
  - tests/rtfclass.prg
  - tests/test10.prg
  - tests/testgt.prg
  * tests/ac_test.prg
  * tests/alias.prg
  * tests/begin.prg
  * tests/boxtest.prg
  * tests/cdow.prg
  * tests/clasinh.prg
  * tests/dates.prg
  * tests/dates2.prg
  * tests/dates3.prg
  * tests/dates4.prg
  * tests/ddate.prg
  * tests/debugtst.prg
  * tests/delimtst.prg
  * tests/devtest.prg
  * tests/disptest.prg
  * tests/foreach.prg
  * tests/gtstdtst.prg
  * tests/ipclnt.prg
  * tests/ipsvr.prg
  * tests/langapi.prg
  * tests/memtst.prg
  * tests/memvar.prg
  * tests/menutest.prg
  * tests/mousetst.prg
  * tests/multiarg.prg
  * tests/newrdd.prg
  * tests/nums.prg
  * tests/objarr.prg
  * tests/objasign.prg
  * tests/objects.prg
  * tests/omacro.prg
  * tests/onidle.prg
  * tests/os.prg
  * tests/output.prg
  * tests/overload.prg
  * tests/parexpr.prg
  * tests/passref.prg
  * tests/procline.prg
  * tests/procname.prg
  * tests/recursiv.prg
  * tests/returns.prg
  * tests/round.prg
  * tests/say.prg
  * tests/sbartest.prg
  * tests/scroll.prg
  * tests/sdf_test.prg
  * tests/seconds.prg
  * tests/server.prg
  * tests/set_num.prg
  * tests/set_test.prg
  * tests/setkeys.prg
  * tests/sound.prg
  * tests/speed.prg
  * tests/statfun.prg
  * tests/statics.prg
  * tests/statics1.prg
  * tests/statics2.prg
  * tests/statinit.prg
  * tests/strdelim.prg
  * tests/stripem.prg
  * tests/switch.prg
  * tests/symbolt.prg
  * tests/t1.prg
  * tests/tb1.prg
  * tests/testbrdb.prg
  * tests/testbrw.prg
  * tests/testcdx.prg
  * tests/testcls.prg
  * tests/testdbf.prg
  * tests/testdecl.prg
  * tests/testerro.prg
  * tests/testfor.prg
  * tests/testget.prg
  * tests/testhrb.prg
  * tests/testhtml.prg
  * tests/testidle.prg
  * tests/testmem.prg
  * tests/testpers.prg
  * tests/testtok.prg
  * tests/testwarn.prg
  * tests/tstalias.prg
  * tests/tstasort.prg
  * tests/tstblock.prg
  * tests/tstdbi.prg
  * tests/tstmacro.prg
  * tests/varparam.prg
  * tests/wvt_fs.prg
    * cleaning up tests
2012-07-18 12:00:10 +00:00

186 lines
5.3 KiB
Plaintext

/*
* $Id$
*/
PROCEDURE Main()
LOCAL nI, aStruct := { { "CHARACTER", "C", 25, 0 }, ;
{ "NUMERIC", "N", 8, 0 }, ;
{ "DOUBLE", "N", 8, 2 }, ;
{ "DATE", "D", 8, 0 }, ;
{ "LOGICAL", "L", 1, 0 }, ;
{ "MEMO1", "M", 10, 0 }, ;
{ "MEMO2", "M", 10, 0 } }
REQUEST DBFCDX
dbCreate( "testdbf", aStruct, "DBFCDX", .T. , "MYALIAS" )
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
? "-"
MYALIAS->( dbAppend() )
MYALIAS->MEMO1 := "Hello world!"
MYALIAS->MEMO2 := "Harbour power"
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
MYALIAS->( dbAppend() )
MYALIAS->MEMO1 := "This is a test for field MEMO1."
MYALIAS->MEMO2 := "This is a test for field MEMO2."
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
MYALIAS->NUMERIC := 90
MYALIAS->DOUBLE := 120.138
? "[" + Str( MYALIAS->DOUBLE ) + "]"
? "[" + Str( MYALIAS->NUMERIC ) + "]"
? ""
? "Press any key..."
Inkey( 0 )
? ""
? "Append 50 records with memos..."
FOR nI := 1 TO 50
MYALIAS->( dbAppend() )
MYALIAS->MEMO1 := "This is a very long string. " + ;
"This may seem silly however strings like this are still " + ;
"used. Not by good programmers though, but I've seen " + ;
"stuff like this used for Copyright messages and other " + ;
"long text. What is the point to all of this you'd say. " + ;
"Well I am coming to the point right now, the constant " + ;
"string is limited to 256 characters and this string is " + ;
"a lot bigger. Do you get my drift ? If there is somebody " + ;
"who has read this line upto the very end: Esto es un " + ;
"sombrero grande rid¡culo." + Chr( 13 ) + Chr( 10 ) + ;
"/" + Chr( 13 ) + Chr( 10 ) + "[;-)" + Chr( 13 ) + Chr( 10 ) + ;
"\"
NEXT
MYALIAS->( dbCommit() )
? "Records before ZAP:", MYALIAS->( LastRec() )
? "Size of files (data and memo):", Directory( "testdbf.dbf" )[1][2], ;
Directory( "testdbf.fpt" )[1][2]
MYALIAS->( __dbZap() )
MYALIAS->( dbCommit() )
? "Records after ZAP:", MYALIAS->( LastRec() )
? "Size of files (data and memo):", Directory( "testdbf.dbf" )[1][2], ;
Directory( "testdbf.fpt" )[1][2]
? "Value of fields MEMO1, MEMO2, DOUBLE and NUMERIC:"
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
? "[" + Str( MYALIAS->DOUBLE ) + "]"
? "[" + Str( MYALIAS->NUMERIC ) + "]"
? "Press any key..."
Inkey( 0 )
dbCloseAll()
dbCreate( "testdbf", aStruct, , .T. , "MYALIAS" )
FOR nI := 1 TO 10
MYALIAS->( dbAppend() )
MYALIAS->NUMERIC := nI
? "Adding a record", nI
IF nI == 3 .OR. nI == 7
MYALIAS->( dbDelete() )
? "Deleting record", nI
ENDIF
NEXT
MYALIAS->( dbCommit() )
? ""
? "With SET DELETED OFF"
? "Press any key..."
Inkey( 0 )
MYALIAS->( dbGoTop() )
DO WHILE !MYALIAS->( EOF() )
? MYALIAS->NUMERIC
MYALIAS->( dbSkip() )
ENDDO
SET DELETED ON
? ""
? "With SET DELETED ON"
? "Press any key..."
Inkey( 0 )
MYALIAS->( dbGoTop() )
DO WHILE !MYALIAS->( EOF() )
? MYALIAS->NUMERIC
MYALIAS->( dbSkip() )
ENDDO
? ""
? "With SET DELETED ON"
? "and SET FILTER TO MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8"
? "Press any key..."
Inkey( 0 )
MYALIAS->( dbSetFilter( { || MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8 }, ;
"MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8" ) )
MYALIAS->( dbGoTop() )
DO WHILE !MYALIAS->( EOF() )
? MYALIAS->NUMERIC
MYALIAS->( dbSkip() )
ENDDO
SET DELETED OFF
? ""
? "With SET DELETED OFF"
? "and SET FILTER TO MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8"
? "Press any key..."
Inkey( 0 )
MYALIAS->( dbSetFilter( { || MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8 }, ;
"MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8" ) )
MYALIAS->( dbGoTop() )
DO WHILE !MYALIAS->( EOF() )
? MYALIAS->NUMERIC
MYALIAS->( dbSkip() )
ENDDO
? "dbFilter() => " + dbFilter()
? ""
? "Testing __dbPack()"
? "Records before PACK:", MYALIAS->( LastRec() )
? "Size of files (data and memo):", Directory( "testdbf.dbf" )[1][2], ;
Directory( "testdbf.dbt" )[1][2]
SET FILTER TO
MYALIAS->( __dbPack() )
MYALIAS->( dbCommit() )
? "Records after PACK:", MYALIAS->( LastRec() )
? "Size of files (data and memo):", Directory( "testdbf.dbf" )[1][2], ;
Directory( "testdbf.dbt" )[1][2]
? "Press any key..."
Inkey( 0 )
? "Value of fields:"
MYALIAS->( dbGoTop() )
DO WHILE !MYALIAS->( EOF() )
? MYALIAS->NUMERIC
MYALIAS->( dbSkip() )
ENDDO
? ""
? "Open test.dbf and LOCATE FOR TESTDBF->SALARY > 145000"
? "Press any key..."
Inkey( 0 )
dbUseArea( , , "test", "TESTDBF" )
LOCATE for TESTDBF->SALARY > 145000
DO WHILE TESTDBF->( Found() )
? TESTDBF->FIRST, TESTDBF->LAST, TESTDBF->SALARY
CONTINUE
ENDDO
? ""
? "LOCATE FOR TESTDBF->MARRIED .AND. TESTDBF->FIRST > 'S'"
? "Press any key..."
Inkey( 0 )
dbUseArea( , , "test", "TESTDBF" )
LOCATE for TESTDBF->MARRIED .AND. TESTDBF->FIRST > 'S'
DO WHILE TESTDBF->( Found() )
? TESTDBF->FIRST, TESTDBF->LAST, TESTDBF->MARRIED
CONTINUE
ENDDO
RETURN