home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
w3_prog
/
db3tpwun.arj
/
DB3DEMUN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-09-12
|
2KB
|
69 lines
{ Simple program to test the DB3 unit DBase file open functions }
{ Requires db3.tpu in current directory }
{ Written by Nigel Salt 1991 - apologies for PASCAL it is not }
{ my first language! }
PROGRAM db3demun;
USES db3,WinCRT;
{************************}
{ MAIN BODY }
{************************}
VAR
testdb: dbfRecord;
testdbflds: ARRAY[1..3] OF _FieldRecord;
testdbfldptr: _dFields;
testdbdata: String;
BEGIN
{Set up fields}
testdbfldptr:=@testdbflds;
testdbflds[1].Name:= 'CUSTOMER';
testdbflds[1].Typ := 'C';
testdbflds[1].Len := 20;
testdbflds[1].Dec := 0;
testdbflds[1].Off := 1;
testdbflds[2].Name:= 'DATE';
testdbflds[2].Typ := 'D';
testdbflds[2].Len := 8;
testdbflds[2].Dec := 0;
testdbflds[2].Off := 21;
testdbflds[3].Name:= 'AMOUNT';
testdbflds[3].Typ := 'N';
testdbflds[3].Len := 16;
testdbflds[3].Dec := 2;
testdbflds[3].Off := 29;
{Create a new database}
CreateDbf(testdb, 'dbintst.dbf', 3, @testdbflds[1]);
{Append 3 records}
{Deleted record flag preceeds each rec so copy to CurRecord^[1]
testdata is astring so copy from testdata[1]}
{012345678901234567890123456789012345678901234}
testdbdata:='ALPHA 19910801-100.11 ';
Move(testdbdata[1],testdb.CurRecord^[1],44);
AppendDbf(testdb);
testdbdata:='BETA 199108022000.22 ';
Move(testdbdata[1],testdb.CurRecord^[1],44);
AppendDbf(testdb);
testdbdata:='GAMMA 19910803330 ';
Move(testdbdata[1],testdb.CurRecord^[1],44);
AppendDbf(testdb);
CloseDbf(testdb);
{Now open and read the three records that were created}
testdb.FileName:='dbintst.dbf';
OpenDbf(testdb);
IF dbfError<>0 THEN WriteDBError
ELSE
BEGIN
WriteDBFormat(testdb);
WriteDBRec(testdb,1);
WriteDBRec(testdb,2);
WriteDBRec(testdb,3);
END;
CloseDbf(testdb);
END.