Marking and Returning to Records

In addition to moving from record to record in a dataset (or moving from one record to another by a specific number of records), you can mark a particular location in a dataset so that you can return to this location. TDataSet introduces a bookmarking feature that consists of a Bookmark property and five bookmark methods. In TMemTable, bookmarks contain the record number (RecNo property). 

The Bookmark property. 

Bookmark gets or sets the current bookmark in a dataset. A bookmark marks a location in a dataset so that an application can easily return to that location quickly. 

An application can read Bookmark to retrieve the bookmark associated with the current record, and it can change the current record in the dataset by assigning a saved bookmark value to this property. 

GetBookmark method 

I do not recommend to use this method, use Bookmark property instead of it. See VCL documentation for detail. 

GotoBookmark and BookmarkValid method 

When passed a bookmark, GotoBookmark moves the cursor for the dataset to the location specified in the bookmark. Before calling GotoBookmark, you can call BookmarkValid to determine if the bookmark points to a record. BookmarkValid returns True if a specified bookmark points to a record. 

CompareBookmarks method 

You can also call CompareBookmarks to see if a bookmark you want to move to is different from another (or the current) bookmark. If the two bookmarks refer to the same record (or if both are nil), CompareBookmarks returns 0. 

FreeBookmark method 

This method is Used in combinations with GetBookamrk. I do not recommend to use this method. See VCL documentation for detail.

Copyright (c) 1998-2013. All rights reserved.
What do you think about this topic? Send feedback!