SOLVED !!!
Show quoted text 24 lines
After to procedure changes (see below). First time procedure is called (file does not exist):
FilePath = /home/pewink/Public/My_code/Lazarus_source/pewink/Hexxpawn/lazarus/0.5.alpha/ TableName = hex8_log.dbf
Starting to add fields with .FieldDefs
finished adding fields.
2.closing trace file.
Opening Trace File.
FindLast record.
3.closing trace file.
2nd time, file exists.
FilePath = /home/pewink/Public/My_code/Lazarus_source/pewink/Hexxpawn/lazarus/0.5.alpha/ TableName = hex8_log.dbf
Opening Trace File.
FindLast record.
3.closing trace file.
procedure TForm1.open_trace_file;
var
S : String;
I : integer;
begin
S := Application.ExeName;
// hack for Mac
I := Pos('.app/Contents/MacOS/', S);
if (I > 0) then
S := Copy(S,1, I+3);
try
begin
Trace_File_DBF := TDbf.Create(nil);
Trace_File_DBF.TableLevel := Longint(TXBaseConst);
Trace_File_DBF.FilePath := ExtractFilePath(S);
Trace_File_DBF.TableName := filename_Trace_File_DBF;
memo1.lines.add( 'FilePath = ' + Trace_File_DBF.FilePath );
memo1.lines.add( 'TableName = ' + Trace_File_DBF.TableName );
Trace_File_DBF.TableLevel := Longint(TXBaseConst);
if not FileExists( filename_Trace_File_DBF ) then
begin
With Trace_File_DBF do
begin
TableLevel := Longint(TXBaseConst);
FilePath := ExtractFilePath(S);
with Trace_File_DBF.FieldDefs do
begin
memo1.lines.add( 'Starting to add fields with .FieldDefs' );
// Trace_File_DBF.FilePathFull := ????????
with Trace_File_DBF.FieldDefs do
begin
Add( 'game_count', ftinteger, 0, True );
[... etc more Add fields here ]
end; // with
memo1.lines.add( 'finished adding fields.' );
end; // with
showmessage( 'Creating Table: Trace File.' );
Trace_File_DBF.CreateTable;
memo1.lines.add( '2.closing trace file.' );
Trace_File_DBF.Close;
end; // with
end; // then
memo1.lines.add( 'Opening Trace File.' );
Trace_File_DBF.Exclusive := true;
Trace_File_DBF.Open;
Trace_File_DBF_open := true;
memo1.lines.add( 'FindLast record.' );
Trace_File_DBF.FindLast;
end; // try
except
memo1.lines.add( 'Exception opening trace file.' );
end;
end; { open_trace_file }