* * *

Author Topic: Bookmarking  (Read 339 times)

kapibara

  • Sr. Member
  • ****
  • Posts: 441
Bookmarking
« on: May 16, 2017, 09:40:53 pm »
According to the doc's, GetBookmark, GotoBookmark and so on is deprecated and TBookmarkStr should be used together with the datasets Bookmark property. https://www.freepascal.org/docs-html/fcl/db/tdataset.bookmark.html

Are these errors because I use fpc 3.0 instead of 3.02 ?

Quote
uMain.pas(54,22) Error: Incompatible types: got "TBytes" expected "AnsiString"
uMain.pas(59,32) Error: Incompatible type for arg no. 1: Got "AnsiString", expected "TBytes"
Code: Pascal  [Select]
  1. var
  2.   bookmark: TBookmarkStr;
  3.  
  4. procedure TForm1.btnSetBookmarkClick(Sender: TObject);
  5. begin
  6.   bookmark:= qryItems.Bookmark;
  7. end;
  8.  
  9. procedure TForm1.btnGoToBookmarkClick(Sender: TObject);
  10. begin
  11.   qryItems.Bookmark := bookmark;
  12. end;
  13.  

« Last Edit: May 16, 2017, 10:10:58 pm by kapibara »
Lazarus trunk / fpc 3.0 / Debian Stretch 64-bit

valdir.marcos

  • Full Member
  • ***
  • Posts: 214
Re: Bookmarking
« Reply #1 on: May 16, 2017, 11:10:04 pm »
First, take a look on this other thread (TBookmark or TBookmarkStr — the confusion, May 06, 2013):

The documentation claims that TBookmark is deprecated in favour of TBookmarkStr, but, in the source, TBookmarkStr is the type which is marked deprecated.

The fpc 2.6.2 documentation (see: http://www.freepascal.org/docs-html/fcl/db/tbookmark.html) says that TBookmark is depracated:
Quote
TBookmark

Bookmark type (deprecated)
Further on the same page, you can read (bold by me):
Quote
TBookMark is the type used by the TDataset.SetBookMark method. It is an opaque type, and should not be used any more, it is superseded by the TBookmarkStr type.

However, the source of db unit (fpc 2.6.2) claims quite opposite:
Code: [Select]
  TBookmark = Pointer;
  TBookmarkStr = string deprecated 'TBookmarkStr will disappear in 2.6.3 in favour of TBookmark';

What is the actual status of these two types? Which one should be used?


TBookmark will stay for sure since it is D2009+ compatible.

Afaik this situation reflects the confusing situation with Delphi where first they steered people towards bookmarkstr (since string and thus managed), but that bit them when they changed the definition of the stringtype, and Embarcadero changed TBookmark to array of byte so that it was also autocleaned.

Currently, FPC 2.6.x leans towards bookmarkstr (older Delphis) and 2.7.x (more D2009+ like) will do both.

kapibara

  • Sr. Member
  • ****
  • Posts: 441
Re: Bookmarking
« Reply #2 on: May 17, 2017, 02:30:03 pm »
Hilarous.  ::)

TBookmark is the way to go then.
Lazarus trunk / fpc 3.0 / Debian Stretch 64-bit

GAN

  • Jr. Member
  • **
  • Posts: 65
Re: Bookmarking
« Reply #3 on: May 17, 2017, 11:24:53 pm »
Code: Pascal  [Select]
  1.     for i:=0 to DBGrid1.SelectedRows.Count-1 do
  2.     with DBGrid1.DataSource.DataSet do
  3.     begin
  4.       GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
  5.       // do something
  6.     end;

Hi @kapibara I use this and works fine, but really don't know if can help you.
Lazarus 1.6 FPC 3.0.0 Linux Mint Mate 17.2 x86_64 GTK-2
Zeos 7.1.3 - Sqlite 3.8.2

Foro Lazarus en español http://forum.lazarus.freepascal.org/index.php/board,73.0.html

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus