Sign in Join

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

Mailing lists / lazarus / 2010-08

Changing Dataset.RecNo to use safer technique of bookmarks (TDbf database files)

1 message · 1 person ·

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,

A few months ago I posted some messages about converting my dBase code (in Delphi) to lazarus. I was advised that I should NOT use Dataset.RecNo but instead I should use bookmarks. Can someone please advise me how to rewrite:

with Hexx_Data_DBF.FieldDefs do
  Hexx_Data_DBF_RecNo := Dataset.RecNo;

to use the safer method of using bookmarks???

type
  { Thxboard }
  Thxboard = class(TForm)
    Hexx_Data_DBF: TDbf;
var
  TraceFile_DBF_RecNo, Hexx_Data_DBF_RecNo : integer;
[...]
    while (not Hexx_Data_DBF.EOF) and not found do
      begin
        if (pattern_is_db_current(pattern1)) then
          begin
            save_options(pattern1);
            found := true;
            //Hexx_Data_DBF_RecNo := Hexx_Data_DBF.RecNo;
            with Hexx_Data_DBF.FieldDefs do
              Hexx_Data_DBF_RecNo := Dataset.RecNo;
            close_db;
            if trace_moves then
              begin
                open_trace_file;
                With Trace_File_DBF do
                try
                  // ### needs changing
                  with Trace_File_DBF.FieldDefs do
                       Dataset.RecNo := (TraceFile_DBF_RecNo);
                  FieldByName('record_no' ).AsInteger :=
Hexx_Data_DBF_RecNo;
                //finally
                except
                  showmessage( 'An exception occured in
write_updated_pattern - writing to trace file.');
                  close_trace_file;
                end;
              end;
            open_db;
            // ### needs changing
            with Hexx_Data_DBF.FieldDefs do
              Dataset.RecNo := (Hexx_Data_DBF_RecNo);
          end;
        // ### needs changing
        Hexx_Data_DBF.Next;
      end;
[...]
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) -------------- next part -------------- A non-text attachment was scrubbed... Name: temp1.pas Type: text/x-pascal Size: 4991 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100831/ceaa2bc8/attachment.bin>