home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
p
/
psppd100.zip
/
TESTPPD.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1992-09-16
|
4KB
|
146 lines
{
╔══════════════════╗
║ Test ║
║ PPDatabase ║
║ Rev. 1.00 ║
╚══════════════════╝
}
{$F-} {$O-} {$A+} {$G-}
{$V-} {$B-} {$X-} {$N+} {$E+}
{$I FINAL.PAS}
{$IFDEF FINAL}
{$I-} {$R-}
{$D-} {$L-} {$S-}
{$ENDIF}
{$M 8192,100000,655360}
Uses DBASE,CRT;
Procedure Error(ErrNum:Word);
Begin
If ErrNum=0 Then Exit; {No Error}
WriteLn('Database Error Report: ',DatabaseErrorMsg(ErrNum),'.');
Halt;
End;
Const
DBName = 'TEST.PPD';
Function Menu:Byte;
Var
C:Char;
Begin
WriteLn;
WriteLn('1. View Database');
WriteLn('2. View Sub Database');
WriteLn('3. Join A Database');
WriteLn('4. Add Data');
WriteLn('5. Delete Data');
WriteLn('6. View Data');
WriteLn;
WriteLn('Press 1 to 6, [Esc] Quits.');
WriteLn;
Repeat
C:=ReadKey;
Until C in ['1'..'6',#27];
If C=#27 Then
Begin
WriteLn('You can now delete or rename the file ',DBName,'.');
Menu:=0;
End
Else
Menu:=Ord(C)-Ord('0');
End;
Var
DB:DBaseFile;
Procedure DDB; {Display Database Directory For User}
Begin
WriteLn;
WriteLn('Name':12,' ','Number':6,' ','Offset':8,' ','Size':6,' ','Attr');
WriteLn;
DB.Dir.Data:=DB.Dir.Root;
While DB.Dir.Data<> NIL do
Begin
With DB.Dir.Data^ do
WriteLn(Name:12,' ',Number:6,' ',Offset:8,' ',Size:6,' ',Attr);
DB.Dir.Data:=DB.Dir.Data^.Next;
End;
End;
Var
IncludeBase :String[79];
St :String[10];
C :Char;
Num,
Er :Word;
QuitNow :Boolean;
Begin
ClrScr;
WriteLn('Creating Database ',DBName,'...');
DB.Init;
Er:=DB.CreateDatabase(DBName,False); {Create a Database}
Er:=DB.OpenDatabase(DBName,0,MaxLongInt); {Open It}
Error(Er);
QuitNow:=False;
Repeat
Case Menu Of
0:QuitNow:=True;
1:DDB;
2:Begin
Write('Select a number: ');
ReadLn(Num);
Er:=DB.CrossIntoDatabase('',Num); {Access Sub-Database}
Error(Er);
DDB;
Er:=DB.CrossOutOfDatabase; {Return to Calling Database}
Error(Er);
End;
3:Begin
Write('Select a new number: ');
ReadLn(Num);
Write('Select a database: ');
ReadLn(IncludeBase);
Er:=DB.NewDataFile('',Num,IncludeBase); {Include Data From File}
Er:=DB.SetDirFlag('',Num,True); {Set Attr to Directory}
Error(Er);
End;
4:Begin
Write('Enter a new number: ');
ReadLn(Num);
Write('Enter a Line of Data: ');
ReadLn(IncludeBase);
Er:=DB.NewData('',Num,Addr(IncludeBase),SizeOf(IncludeBase)); {Add Line of Data}
Error(Er);
End;
5:Begin
Write('Enter a number: ');
ReadLn(Num);
Er:=DB.DelData('',Num);
Error(Er);
End;
6:Begin
Write('Enter a number: ');
ReadLn(Num);
Er:=DB.GetData('',Num,Addr(IncludeBase)); {Get Line of Data}
Error(Er);
WriteLn('Collected: ',IncludeBase);
End;
End;
Until QuitNow;
Er:=DB.CloseDatabase; {Don't forget to Close it}
Error(Er);
End.