Sign in Join

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

Mailing lists / lazarus / 2023-05

locate command for dBase

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

john Ward

I need to find records in an indexed dBase file based on a key. version is 2.2.6 fpc 3.2.2 x86_64.

The following is the test I did in the program. The dBase file is temp.dbf and the index if temp.mdx; The program includes tDbf and tDatasource. I also have tDbnavigator in the program, all seems to be working, adding, editing records. I need to be able to 'find' a record in the data base, so editing can be done, without going through record by record.

procedure Ttempf.Edit1Exit(Sender: TObject);
var
   tempid : string;
   tno : string;
begin
     tempid := edit1.text;
  if
  temp.Locate('temp_no', (tempid),[loPartialkey])
  then
  begin
    showmessage('we found the field or Partial' + tempid);
    showmessage('current temp_no is ');
    tno := temp.FieldbyName('temp_no').asString;
   showmessage('tempno is = ' + tno);
    end;

The above code, executes the 'then', shows me what was searched for BUT when a data field is displayed, the original record is pointed to, NOT a record further in the database.

Driving myself crazy trying to find problem, It is a short drive, many times. any Help would be appreciated.

John A. Ward, President

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20230525/627e2891/attachment.htm>

Reply by email

Unknown author
to john Ward
john Ward wrote 13 lines
? if ? temp.Locate('temp_no', (tempid),[loPartialkey]) ? then ? begin ? ? showmessage('we found the field or Partial' + tempid); ? ? showmessage('current temp_no is '); ? ? tno := temp.FieldbyName('temp_no').asString; ?? showmessage('tempno is = ' + tno); ? ? end; The above code, executes the 'then', shows me what was searched for BUT when a data field is displayed, the original record is pointed to, NOT a record further in the database.

i don't see where you did a seek to the record you are trying to get to... granted, it has been a long while since i did anything with FPC/Lazarus or an dBase databases but it would seem there should be an obvious seek action... maybe...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!*

Reply by email

Michael Van Canneyt
to Unknown author
wkitty42--- wrote 22 lines
On 5/25/23 8:12 PM, john Ward via lazarus wrote: > ? if > ? temp.Locate('temp_no', (tempid),[loPartialkey]) > ? then > ? begin > > ? ? showmessage('we found the field or Partial' + tempid); > ? ? showmessage('current temp_no is '); > ? ? tno := temp.FieldbyName('temp_no').asString; > ?? showmessage('tempno is = ' + tno); > ? ? end; > The above code, executes the 'then', shows me what was searched for BUT when a > data field is displayed, the original record is pointed to, NOT a record further > in the database. i don't see where you did a seek to the record you are trying to get to... granted, it has been a long while since i did anything with FPC/Lazarus or an dBase databases but it would seem there should be an obvious seek action... maybe...

the locate() is a seek action.

But without more info/code it is difficult to give an answer to the OP's question.

Michael.

Reply by email

Unknown author
to Michael Van Canneyt
Michael Van Canneyt wrote 7 lines
On Fri, 26 May 2023, wkitty42--- via lazarus wrote: > i don't see where you did a seek to the record you are trying to get to... > granted, it has been a long while since i did anything with FPC/Lazarus or an > dBase databases but it would seem there should be an obvious seek action... > maybe... the locate() is a seek action.

ahhhh... i thought it just located whatever is being sought and one still needed to actually seek to the record...

But without more info/code it is difficult to give an answer to the OP's question.

agreed :)

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!*

Reply by email