SpdBtnPMSDataRebuild.Enabled:= False;
PrgrsBarTableRebld.Position:= 5;
ForceDirectories('PMS Data'); { Note: PMS Database Directory = PMS Data }
if FileExists('Appointments.dbf') then
DeleteFile('Appointments.dbf');
Appointments := TDbf.Create(nil);
try
// ForceDirectories('PMS Data');
{ Use the relative path to the "PMS Data" directory }
Appointments.FilePath := 'PMS Data' + DirectorySeparator;
{ Use Visual dBase VII compatible tables for Lazarus }
Appointments.TableLevel:= 7;
Appointments.Exclusive:= True;
Appointments.TableName:= 'Appointments.dbf';
with Appointments.FieldDefs do begin
PrgrsBarTableRebld.Step:= 10;
PrgrsBarTableRebld.Position:= 10;
Add('APPTID', ftAutoInc, 4, True);
Add('APPTDATETIME', ftDateTime, 8, True); // Do I leave the field length empty here???
Add('CNTKLNAME', ftString, 15, True);
Add('CNTKFNAME', ftString, 15, True);
Add('CNTKMI', ftString, 1, True);
Add('CLIENT', ftString, 25, True);
Add('PHONE', ftString, 15, True);
Add('EMAIL', ftString, 25, True);
Add('ADDRESS', ftString, 30, True);
Add('CITY', ftString, 25, True);
Add('STATEPROV', ftString, 2, True);
Add('POSTALCODE', ftString, 10, True);
Add('DIRECTIONS', ftMemo, 10, True);
Add('NOTES', ftMemo, 10, True)
end;
Appointments.CreateTable;
Appointments.Open;
PrgrsBarTableRebld.Position:= 30;
{Add the primary index}
Appointments.AddIndex('APPTNO','APPTID',[ixPrimary]);
{Add a secondary indexes}
Appointments.AddIndex('APPTDTIME','DTOS(APPTDATETIME)',[]);
Appointments.AddIndex('CNTKNAME','CNTKLNAME+CNTKFNAME+CNTKMI',
[ixExpression, ixCaseInsensitive]);
Appointments.AddIndex('CLIENT','CLIENT',[ixCaseInsensitive]);
Appointments.Close;
finally
Appointments.Free;
end;