Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-06

Functions, procedures etc for using Dbase3/4 files ... what are they in Lazarus? (I used XBase1 in Delphi 5)

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Peter E Williams

Hi All,

I really need to know what is the Dbase3/4 unit for Lazarus/Free Pascal and where is the sample project for manipulating them. I found it somewhere on the lazarus website but don't know where. I hope that it is okay for me to post some of my code which uses the XBase1 unit in Delphi 5 Enterprise which I am porting to my Hexxpawn8 game (which is cross platform open source).

I use Dbase3/4+ files to store board patterns for my game which is sort of a cross between the pawns in Chess and checkers, using AI logic against the computer. (I chose Dbase format because it was the single most common database file format at the time.)

What is the replacement unit for XBase1 for using Dbase3/4 files, and the functions/procedures etc to replace these calls to XBase1 ?

How do I do the following:

// declaring a Dbase file -- TXBase (what is the equivalent in Lazarus?)
// how do I copy a blank.dfg file to hex8.bdf (Copyfile) ???
// I need to Goto to the Bottom of File (HexxData.GotoBOF;)
// I need to call a function GetFieldByName passing a string as the
field name and comparing it with a character
// I need to Goto the Next record (HexxData.GotoNext;)
// I need to Get the Record # (HexxData.RecNo;)
// and test the Dbase.EOF (not HexxData.EOF)
// and Append a Blank record (HexxData.AppendBlank;)
// save an integer to a Field (HexxData.UpdFieldStr('this_game',
inttostr(pattern.this_game)); )
// and Goto to the Record number (HexxData.GotoRecord(hexxdata_rec_no);)

See examples of my code below

Unit hexboard2.pas

// declaring a Dbase file -- TXBase
var
  HexxData, TraceFile: TXBase;
procedure Thxboard.Open_db;
begin
  if not fileExists('hex8.dbf') then
    CopyFile('blank.dbf', 'hex8.dbf', false);
// how do I copy a blank.dfg file to hex8.bdf ???
  HexxData := TXBase.create(nil);
// I assume that this is how to create a replacement for a Dbase file
  HexxData.FileName := 'hex8.dbf';
  HexxData.Active := true;
  HexxData.GotoBOF;
// I need to Goto to the Bottom of File
end; { Open_db }
function Thxboard.pattern_is_db_current(pattern1: pattern_type):
boolean;
var
  str_x, str_o: array[1..8] of string;
begin
  pattern_is_db_current := false;
  str(pattern1.x_piece[1], str_x[1]);
 // ..
  if (HexxData.GetFieldByName('x1_pos') = str_x[1]) and
// I need to call a function GetFieldByName passing a string as the
field name and comparing it with a character

//..
(HexxData.GetFieldByName('x8_pos') = str_x[8]) then if (HexxData.GetFieldByName('o1_pos') = str_o[1]) and //..
(HexxData.GetFieldByName('o8_pos') = str_o[8]) then

      pattern_is_db_current := true;

end; { pattern_is_db_current }
{---------------------------------------------------------}

procedure Thxboard.Find_pattern(var pattern1: pattern_type;
  var found: boolean);
begin
//,,
        HexxData.GotoNext;
// I need to Goto the Next record

end; { Find_pattern }
{---------------------------------------------------------}

procedure Thxboard.write_updated_pattern(var pattern1: pattern_type);
var
  found: boolean;
begin
  found := false;
  if pattern_is_db_current(pattern1) then
    { save pattern options to db }
    begin
      save_options(pattern1);
      hexxdata_rec_no := HexxData.RecNo;
// I need to Get the Record #
      close_db;
      if trace_moves then
//..
      open_db;
      HexxData.GotoRecord(hexxdata_rec_no);
// then I need to Goto to record #
    end
  else
  { save entire pattern to db };
  begin
    while (not HexxData.EOF) and not found do
// and test the Dbase.EOF (end of file)
      begin
//..
      end;
    if not found then
      begin
      { --- add a new record --- }
        HexxData.AppendBlank;
// and Append a Blank record
        save_options(pattern1);
        HexxData.UpdFieldStr('this_game', inttostr(pattern.this_game));
// save an integer to a Field
//..
        hexxdata_rec_no := HexxData.RecNo;
        close_db;
        if trace_moves then
//..
	open_db;
        HexxData.GotoRecord(hexxdata_rec_no);
// and Goto to the Record number
      end; // if found
  end; // else
end; { write_updated_pattern  }
{---------------------------------------------------------}
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)

Reply by email

Michael Van Canneyt
to Peter E Williams

You may want to look at the TDBF component. I think the package is called lazdbf or dbflaz.

Michael.

Peter E Williams wrote 151 lines
Hi All, I really need to know what is the Dbase3/4 unit for Lazarus/Free Pascal and where is the sample project for manipulating them. I found it somewhere on the lazarus website but don't know where. I hope that it is okay for me to post some of my code which uses the XBase1 unit in Delphi 5 Enterprise which I am porting to my Hexxpawn8 game (which is cross platform open source). I use Dbase3/4+ files to store board patterns for my game which is sort of a cross between the pawns in Chess and checkers, using AI logic against the computer. (I chose Dbase format because it was the single most common database file format at the time.) What is the replacement unit for XBase1 for using Dbase3/4 files, and the functions/procedures etc to replace these calls to XBase1 ? How do I do the following: // declaring a Dbase file -- TXBase (what is the equivalent in Lazarus?) // how do I copy a blank.dfg file to hex8.bdf (Copyfile) ??? // I need to Goto to the Bottom of File (HexxData.GotoBOF;) // I need to call a function GetFieldByName passing a string as the field name and comparing it with a character // I need to Goto the Next record (HexxData.GotoNext;) // I need to Get the Record # (HexxData.RecNo;) // and test the Dbase.EOF (not HexxData.EOF) // and Append a Blank record (HexxData.AppendBlank;) // save an integer to a Field (HexxData.UpdFieldStr('this_game', inttostr(pattern.this_game)); ) // and Goto to the Record number (HexxData.GotoRecord(hexxdata_rec_no);) See examples of my code below Unit hexboard2.pas // declaring a Dbase file -- TXBase var HexxData, TraceFile: TXBase; procedure Thxboard.Open_db; begin if not fileExists('hex8.dbf') then CopyFile('blank.dbf', 'hex8.dbf', false); // how do I copy a blank.dfg file to hex8.bdf ??? HexxData := TXBase.create(nil); // I assume that this is how to create a replacement for a Dbase file HexxData.FileName := 'hex8.dbf'; HexxData.Active := true; HexxData.GotoBOF; // I need to Goto to the Bottom of File end; { Open_db } function Thxboard.pattern_is_db_current(pattern1: pattern_type): boolean; var str_x, str_o: array[1..8] of string; begin pattern_is_db_current := false; str(pattern1.x_piece[1], str_x[1]); // .. if (HexxData.GetFieldByName('x1_pos') = str_x[1]) and // I need to call a function GetFieldByName passing a string as the field name and comparing it with a character //.. (HexxData.GetFieldByName('x8_pos') = str_x[8]) then if (HexxData.GetFieldByName('o1_pos') = str_o[1]) and //.. (HexxData.GetFieldByName('o8_pos') = str_o[8]) then pattern_is_db_current := true; end; { pattern_is_db_current } {---------------------------------------------------------} procedure Thxboard.Find_pattern(var pattern1: pattern_type; var found: boolean); begin //,, HexxData.GotoNext; // I need to Goto the Next record end; { Find_pattern } {---------------------------------------------------------} procedure Thxboard.write_updated_pattern(var pattern1: pattern_type); var found: boolean; begin found := false; if pattern_is_db_current(pattern1) then { save pattern options to db } begin save_options(pattern1); hexxdata_rec_no := HexxData.RecNo; // I need to Get the Record # close_db; if trace_moves then //.. open_db; HexxData.GotoRecord(hexxdata_rec_no); // then I need to Goto to record # end else { save entire pattern to db }; begin while (not HexxData.EOF) and not found do // and test the Dbase.EOF (end of file) begin //.. end; if not found then begin { --- add a new record --- } HexxData.AppendBlank; // and Append a Blank record save_options(pattern1); HexxData.UpdFieldStr('this_game', inttostr(pattern.this_game)); // save an integer to a Field //.. hexxdata_rec_no := HexxData.RecNo; close_db; if trace_moves then //.. open_db; HexxData.GotoRecord(hexxdata_rec_no); // and Goto to the Record number end; // if found end; // else end; { write_updated_pattern } {---------------------------------------------------------} -- 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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Howard Page-Clark
to Peter E Williams: I really need to know what is the Dbase3/4 unit for Lazarus/Free Pascal and where is the…
Peter E Williams wrote 22 lines
Hi All, I really need to know what is the Dbase3/4 unit for Lazarus/Free Pascal and where is the sample project for manipulating them. I found it somewhere on the lazarus website but don't know where. I hope that it is okay for me to post some of my code which uses the XBase1 unit in Delphi 5 Enterprise which I am porting to my Hexxpawn8 game (which is cross platform open source). I use Dbase3/4+ files to store board patterns for my game which is sort of a cross between the pawns in Chess and checkers, using AI logic against the computer. (I chose Dbase format because it was the single most common database file format at the time.) What is the replacement unit for XBase1 for using Dbase3/4 files, and the functions/procedures etc to replace these calls to XBase1 ? How do I do the following: // declaring a Dbase file -- TXBase (what is the equivalent in Lazarus?) // I need to Get the Record # (HexxData.RecNo;)

<snip>

For a general introduction have a look at
http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial For using Tdbf have a look at
http://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial

Under Windows you would find the dbflaz.lpk package in lazarus\components\tdbf\

There is an example application using Tdbf in lazarus\examples\addressbook\

You are best to avoid use of record numbers for locating records altogether. Use the LocateRecord() method of Tdbf of one of its variants instead.

Howard

Reply by email

Peter E Williams
to Michael Van Canneyt: You may want to look at the TDBF component. I think the package is called lazdbf or…

Hi All,

Michael Van Canneyt wrote 5 lines
You may want to look at the TDBF component. I think the package is called lazdbf or dbflaz. Michael.
Howard Page-Clark wrote
For a general introduction have a look at http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial

I have looked at this document

and printed out and read this one.

and I have studied the Address Example and the other database example.

// need changing 0.50.alpha
//(Sender as Taction).Enabled:=Active;
if (GetFieldByName('x1_pos') = str_x[1]) and

I cannot find what to change XBase1's GetFieldByName(string) function to. It accepts a field name as a parameter and returns a string.

// #### how do I do this
HexxData_DBF.UpdFieldStr('x' + inttostr(x) + '_left',
option_2_str(pattern1.option[x, 1]));

I cannot find what to change XBase1's UpdFieldStr(string, string) function. The first parameter is the field name e.g. 'x1_left' and the second parameter is a string value to assign to the first parameter.

HexxData_DBF.AppendBlank;
Is this how I append a blank record? The documents quoted above don't mention appending a blank record.

HexxData_DBF_rec_no := HexxData_DBF.RecNo;
I need to get the record number and assign it to a longint
HexxData_DBF.GotoRecord(HexxData_DBF_rec_no); // ### needs changing
Then I need a Function to Goto the Record saved in the above assignment

My code:

{ this procedure nicked from Address Example }
procedure Thxboard.ACloseUpdate(Sender: TObject; DBFName : TDbf);
begin
  (Sender as Taction).Enabled:=Not (DBFName.State in dsEditModes);
end;
{----------------------------------------------------------}
procedure Thxboard.Open_db;
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
    HexxData_DBF.TableLevel := 3; // dBase III+
    HexxData_DBF.TableName := 'hex8.dbf';
    //  if not fileExists(S) then
    //  CopyFile('blank.dbf', S, false);
    //HexxData_DBF := TXBase.create(nil);
    HexxData_DBF.FilePath := ExtractFilePath(S) + 'data' + PathDelim;
    HexxData_DBF.Open;
    //HexxData_DBF.Active := true;
    //HexxData_DBF.GotoBOF;
  //finally
  except
    HexxData_DBF.free; // don't know what goes here.
  end;
end; { Open_db }
{---------------------------------------------------------}
procedure Thxboard.Close_db;
begin
  Caption := 'Saving patterns database...';
  refresh;
  if HexxData_DBF.Exclusive then
    begin
    try
      // HexxData_DBF.FileName := 'hex8.dbf';
      caption := 'One moment please...';
      //  HexxData_DBF.Active := false;
      //  HexxData_DBF.Destroy;
      ACloseUpdate(HexxData_DBF);
      //HexxData_DBF.Close;
    //finally
    except
      HexxData_DBF.Free;
    end;
  end;
end; { Close_db }
{---------------------------------------------------------}
function Thxboard.pattern_is_db_current(pattern1: pattern_type):
boolean;
var
  str_x, str_o: array[1..8] of string;
begin
  pattern_is_db_current := false;
  str(pattern1.x_piece[1], str_x[1]);
  str(pattern1.x_piece[2], str_x[2]);
  str(pattern1.x_piece[3], str_x[3]);
  str(pattern1.x_piece[4], str_x[4]);
  str(pattern1.x_piece[5], str_x[5]);
  str(pattern1.x_piece[6], str_x[6]);
  str(pattern1.x_piece[7], str_x[7]);
  str(pattern1.x_piece[8], str_x[8]);
  str(pattern1.o_piece[1], str_o[1]);
  str(pattern1.o_piece[2], str_o[2]);
  str(pattern1.o_piece[3], str_o[3]);
  str(pattern1.o_piece[4], str_o[4]);
  str(pattern1.o_piece[5], str_o[5]);
  str(pattern1.o_piece[6], str_o[6]);
  str(pattern1.o_piece[7], str_o[7]);
  str(pattern1.o_piece[8], str_o[8]);
  with HexxData_DBF do
  begin
    try
      HexxData_DBF.TableLevel := 3; // dBase III+
      Exclusive := True;
      with HexxData_DBF.FieldDefs do
      begin
        // need changing 0.50.alpha
        //(Sender as Taction).Enabled:=Active;
        if (GetFieldByName('x1_pos') = str_x[1]) and
           (GetFieldByName('x2_pos') = str_x[2]) and
           (GetFieldByName('x3_pos') = str_x[3]) and
           (GetFieldByName('x4_pos') = str_x[4]) and
           (GetFieldByName('x5_pos') = str_x[5]) and
           (GetFieldByName('x6_pos') = str_x[6]) and
           (GetFieldByName('x7_pos') = str_x[7]) and
           (GetFieldByName('x8_pos') = str_x[8]) then
             if (GetFieldByName('o1_pos') = str_o[1]) and
                (GetFieldByName('o2_pos') = str_o[2]) and
                (GetFieldByName('o3_pos') = str_o[3]) and
                (GetFieldByName('o4_pos') = str_o[4]) and
                (GetFieldByName('o5_pos') = str_o[5]) and
                (GetFieldByName('o6_pos') = str_o[6]) and
                (GetFieldByName('o7_pos') = str_o[7]) and
                (GetFieldByName('o8_pos') = str_o[8]) then
                pattern_is_db_current := true;
        end
      HexxData_DBF.Exclusive := False; // added 0.50.alpha
      // HexxData_DBF.Close; // added 0.50.alpha
    except
//    finally
      HexxData_DBF.Free; // added 0.50.alpha
    end;
  end;
end; { pattern_is_db_current }
{---------------------------------------------------------}
procedure Thxboard.save_options(pattern1: pattern_type);
var
  x: integer;
begin
  for x := 1 to 8 do
    begin
      // #### how do I do this
      HexxData_DBF.UpdFieldStr('x' + inttostr(x) + '_left',
option_2_str(pattern1.option[x, 1]));
      HexxData_DBF.UpdFieldStr('x' + inttostr(x) + '_forward',
option_2_str(pattern1.option[x, 2]));
      HexxData_DBF.UpdFieldStr('x' + inttostr(x) + '_right',
option_2_str(pattern1.option[x, 3]));
    end;
end; { save_options }
{---------------------------------------------------------}
procedure Thxboard.write_updated_pattern(var pattern1: pattern_type);
var
  found: boolean;
begin
  found := false;
  if pattern_is_db_current(pattern1) then
    { save pattern options to db }
    begin
      save_options(pattern1);
      // #### how do I do this
      HexxData_DBF_rec_no := HexxData_DBF.RecNo;
      close_db;
      if trace_moves then
        begin
          open_trace_file;
          With TraceFile_DBF do
          try
            // #### needs changing
            TraceFile_DBF.GotoRecord(trace_rec_no);
            TraceFile_DBF.UpdFieldStr('record_no',
inttostr(HexxData_DBF_rec_no));
          //finally
          except
            close_trace_file;
          end;
        end;
      open_db;
      // #### how do I do this
      HexxData_DBF.GotoRecord(HexxData_DBF_rec_no);
    end
  else
  { save entire pattern to db };
  begin
    while (not HexxData_DBF.EOF) and not found do
      begin
        if (pattern_is_db_current(pattern1)) then
          begin
            save_options(pattern1);
            found := true;
            HexxData_DBF_rec_no := HexxData_DBF.RecNo;
            close_db;
            if trace_moves then
              begin
                open_trace_file;
                With TraceFile_DBF do
                try
                  // ### needs changing
                  TraceFile_DBF.GotoRecord(trace_rec_no);
                  TraceFile_DBF.UpdFieldStr('record_no',
inttostr(HexxData_DBF_rec_no));
                //finally
                except
                  close_trace_file;
                end;
              end;
            open_db;
            // ### needs changing
            HexxData_DBF.GotoRecord(HexxData_DBF_rec_no);
          end;
        // ### needs changing
        HexxData_DBF.Next;
      end;
    if not found then
      begin
        with HexxData_DBF
        try
          HexxData_DBF.AppendBlank;
          With HexxData_DBF.FieldDefs do
          begin
               { --- add a new record --- }
               save_options(pattern1);
               // ### needs changing
               HexxData_DBF.UpdFieldStr('this_game',
inttostr(pattern.this_game));
               HexxData_DBF.UpdFieldStr('x1_pos',
inttostr(pattern1.x_piece[1]));
               HexxData_DBF.UpdFieldStr('x2_pos',
inttostr(pattern1.x_piece[2]));
               HexxData_DBF.UpdFieldStr('x3_pos',
inttostr(pattern1.x_piece[3]));
               HexxData_DBF.UpdFieldStr('x4_pos',
inttostr(pattern1.x_piece[4]));
               HexxData_DBF.UpdFieldStr('x5_pos',
inttostr(pattern1.x_piece[5]));
               HexxData_DBF.UpdFieldStr('x6_pos',
inttostr(pattern1.x_piece[6]));
               HexxData_DBF.UpdFieldStr('x7_pos',
inttostr(pattern1.x_piece[7]));
               HexxData_DBF.UpdFieldStr('x8_pos',
inttostr(pattern1.x_piece[8]));
               HexxData_DBF.UpdFieldStr('o1_pos',
inttostr(pattern1.o_piece[1]));
               HexxData_DBF.UpdFieldStr('o2_pos',
inttostr(pattern1.o_piece[2]));
               HexxData_DBF.UpdFieldStr('o3_pos',
inttostr(pattern1.o_piece[3]));
               HexxData_DBF.UpdFieldStr('o4_pos',
inttostr(pattern1.o_piece[4]));
               HexxData_DBF.UpdFieldStr('o5_pos',
inttostr(pattern1.o_piece[5]));
               HexxData_DBF.UpdFieldStr('o6_pos',
inttostr(pattern1.o_piece[6]));
               HexxData_DBF.UpdFieldStr('o7_pos',
inttostr(pattern1.o_piece[7]));
               HexxData_DBF.UpdFieldStr('o8_pos',
inttostr(pattern1.o_piece[8]));
               HexxData_DBF_rec_no := HexxData_DBF.RecNo;
          end;
        //finally
        except
          close_db;
        end;
        if trace_moves then
          begin
            open_trace_file;
            with TraceFile_DBF
            try
              With TraceFile_DBF.FieldDefs do
              begin
                // ### needs changing
                TraceFile_DBF.GotoRecord(trace_rec_no);
                TraceFile_DBF.UpdFieldStr('record_no',
inttostr(HexxData_DBF_rec_no));
              end;
            //finally
            except
              close_trace_file;
            end;
          end;
        open_db;
        // ### needs changing
        HexxData_DBF.GotoRecord(HexxData_DBF_rec_no);
      end; // if found
  end; // else

end; { write_updated_pattern }
{---------------------------------------------------------}

Best Regards,
Peter

Show quoted text 43 lines
On Tue, 15 Jun 2010, Peter E Williams wrote: > Hi All, > > I really need to know what is the Dbase3/4 unit for Lazarus/Free Pascal > and where is the sample project for manipulating them. I found it > somewhere on the lazarus website but don't know where. I hope that it is > okay for me to post some of my code which uses the XBase1 unit in Delphi > 5 Enterprise which I am porting to my Hexxpawn8 game (which is cross > platform open source). > > I use Dbase3/4+ files to store board patterns for my game which is sort > of a cross between the pawns in Chess and checkers, using AI logic > against the computer. (I chose Dbase format because it was the single > most common database file format at the time.) > > What is the replacement unit for XBase1 for using Dbase3/4 files, and > the functions/procedures etc to replace these calls to XBase1 ? > > How do I do the following: > > // declaring a Dbase file -- TXBase (what is the equivalent in Lazarus?) > // how do I copy a blank.dfg file to hex8.bdf (Copyfile) ??? > // I need to Goto to the Bottom of File (HexxData.GotoBOF;) > // I need to call a function GetFieldByName passing a string as the > field name and comparing it with a character > // I need to Goto the Next record (HexxData.GotoNext;) > // I need to Get the Record # (HexxData.RecNo;) > // and test the Dbase.EOF (not HexxData.EOF) > // and Append a Blank record (HexxData.AppendBlank;) > // save an integer to a Field (HexxData.UpdFieldStr('this_game', > inttostr(pattern.this_game)); ) > // and Goto to the Record number (HexxData.GotoRecord(hexxdata_rec_no);) >
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)

Reply by email

Joost van der Sluis
to Peter E Williams
Peter E Williams wrote 28 lines
Hi All, On Mon, 2010-06-14 at 17:37 +0200, Michael Van Canneyt wrote: > You may want to look at the TDBF component. I think the package is > called > lazdbf or dbflaz. > > Michael. On Mon Jun 14 18:00:51 CEST 2010, Howard Page-Clark wrote: > For a general introduction have a look at > http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial I have looked at this document > For using Tdbf have a look at > http://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial and printed out and read this one. and I have studied the Address Example and the other database example. // need changing 0.50.alpha //(Sender as Taction).Enabled:=Active; if (GetFieldByName('x1_pos') = str_x[1]) and I cannot find what to change XBase1's GetFieldByName(string) function to. It accepts a field name as a parameter and returns a string.
Dataset.FieldByName('fieldname').AsString;
Show quoted text 7 lines
// #### how do I do this HexxData_DBF.UpdFieldStr('x' + inttostr(x) + '_left', option_2_str(pattern1.option[x, 1])); I cannot find what to change XBase1's UpdFieldStr(string, string) function. The first parameter is the field name e.g. 'x1_left' and the second parameter is a string value to assign to the first parameter.
Dataset.FieldByName('FieldName').AsString := NewValue;
HexxData_DBF.AppendBlank; Is this how I append a blank record? The documents quoted above don't mention appending a blank record.
Dataset.Append; <nothing in between, so it's blank> Dataset.Post;
HexxData_DBF_rec_no := HexxData_DBF.RecNo; I need to get the record number and assign it to a longint
Using records numbers is evil! But it'll work in the tDbf (Dbase) case:
Rec_No := dataset.RecNo;
HexxData_DBF.GotoRecord(HexxData_DBF_rec_no); // ### needs changing Then I need a Function to Goto the Record saved in the above assignment
Dataset.RecNo := Rec_No;

But you shouldn't use that. Use bookmarks instead.

Joost.

Reply by email

Peter E Williams
to Joost van der Sluis

Hi Joost & All,

Joost van der Sluis wrote 15 lines
On Tue, 2010-06-15 at 14:54 +1000, Peter E Williams wrote: > > On Mon Jun 14 18:00:51 CEST 2010, Howard Page-Clark wrote: > > For a general introduction have a look at > > http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial > > I have looked at this document > > > For using Tdbf have a look at > > http://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial > Dataset.FieldByName('fieldname').AsString; Dataset.FieldByName('FieldName').AsString := NewValue; Dataset.Append; <nothing in between, so it's blank> Dataset.Post; Dataset.RecNo := Rec_No;

I have spent all morning making those changes. Thank you, Joost !!! :-)))

But you shouldn't use that. Use bookmarks instead.

Do you have a url for a tutorial about bookmarks or some sample code? I would really appreciate it.

Joost.

Peter

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)

Reply by email

Graeme Geldenhuys
to Peter E Williams
Peter E Williams wrote
> But you shouldn't use that. Use bookmarks instead. Do you have a url for a tutorial about bookmarks or some sample code? I would really appreciate it.

I don't use DB-aware components, but maybe these docs or of use... there is an example of it's usage too.

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/DB_TDataSet_FreeBookmark.html

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email