Recent

Author Topic: [SOLVED] Jump to BOF, the first record in a table?  (Read 1362 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
[SOLVED] Jump to BOF, the first record in a table?
« on: February 15, 2024, 11:12:56 pm »
Searching thru several docs for Laz/FPC and can't find an example for jumping to the first record or beginning of file.  Here's an example of BoF for a dBase table:

DbfClients.BOF which is boolean but that context won't compile. I tried DbfClients.BOF:= True and I tried   DbfContacts.DataSource.DataSet.BOF, etc.

Is there a way to jump to the first record or rather, refresh the DBGrid after changing the index.

I reindexed the table and the DBGrid started behaving properly but still would like to force BoF or EoF.

 
« Last Edit: February 16, 2024, 07:49:19 pm by 1HuntnMan »

lainz

  • Hero Member
  • *****
  • Posts: 4738
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Jump to BOF, the first record in a table?
« Reply #1 on: February 15, 2024, 11:20:22 pm »
Hi, I usually use

Code: Pascal  [Select][+][-]
  1. .first();

Edit:

As well

Code: Pascal  [Select][+][-]
  1. .last();
« Last Edit: February 15, 2024, 11:33:54 pm by lainz »

dsiders

  • Hero Member
  • *****
  • Posts: 1464
Re: Jump to BOF, the first record in a table?
« Reply #2 on: February 16, 2024, 03:10:32 am »
Searching thru several docs for Laz/FPC and can't find an example for jumping to the first record or beginning of file.  Here's an example of BoF for a dBase table:

DbfClients.BOF which is boolean but that context won't compile. I tried DbfClients.BOF:= True and I tried   DbfContacts.DataSource.DataSet.BOF, etc.

Is there a way to jump to the first record or rather, refresh the DBGrid after changing the index.

I reindexed the table and the DBGrid started behaving properly but still would like to force BoF or EoF.

TDataset.First
https://lazarus-ccr.sourceforge.io/docs/fcl/db/tdataset.first.html

TDataset.Last
https://lazarus-ccr.sourceforge.io/docs/fcl/db/tdataset.last.html

Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Jump to BOF, the first record in a table?
« Reply #3 on: February 16, 2024, 07:48:55 pm »
Thanks all, got in my personal Laz doc. Seems like I used to use BoF and EoF in Delphi long time ago for Last and First but can't remember.
« Last Edit: February 16, 2024, 08:47:36 pm by 1HuntnMan »

Thaddy

  • Hero Member
  • *****
  • Posts: 18324
  • Here stood a man who saw the Elbe and jumped it.
Re: Jump to BOF, the first record in a table?
« Reply #4 on: February 16, 2024, 08:18:27 pm »
Thanks all, got in my personal Laz doc. Seems like I used to use BoF and EoF in Delphi long time ago but can't remember.
Both are still supported by FreePascal, but refer to type File of <untyped, text or record>, way before TDataset and still work if you want to write a database  from scratch.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

dseligo

  • Hero Member
  • *****
  • Posts: 1601
Re: Jump to BOF, the first record in a table?
« Reply #5 on: February 17, 2024, 01:46:48 am »
Thanks all, got in my personal Laz doc. Seems like I used to use BoF and EoF in Delphi long time ago for Last and First but can't remember.

BOF and EOF exists, but they are read-only properties - you can test them to know if you are at the beginning or at the end of table (dataset).

 

TinyPortal © 2005-2018