SOLVED !!! On Wed, 01 Sep 2010 13:00:50 -0400 waldo kitty wrote: > On 9/1/2010 08:45, Peter E Williams wrote: > > Hi all, > > > > This one is really puzzling. I thought that I was doing everything okay > > to generate a new TDBF file... but I cannot create the file. The > > following is tracetestUnit1.pas which is a test unit to create a dBase > > format TDbf database file. > > > > Output to memo1 follows: > > > > FilePath > > = > > /home/pewink/Public/My_code/Lazarus_source/pewink/Hexxpawn/lazarus/0.5.alpha/ > > TableName = hex8_log.dbf > > Trace File does not exist. > > closing Trace file. > > ummm.... the file doesn't exist yet you close it anyway without it having > been > opened? > > > Starting to add fields with .FieldDefs > > finished adding fields. > > closing trace file. > > Opening Trace File. > > Exception opening trace file.
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 } -- Proudly developing Quality Cross Platform Open Source Games Since 1970 with a Commodore PET 4016 with 16 KRAM http://pews-freeware-games.org (<--- brand new) -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus