🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.delphi.misc
4 messages
4 total messages Started by Gabriele Cardinali Tue, 21 Jul 1998 00:00
Problem with partial search. Please help me!!!!
#94
Author: Gabriele Cardinali
Date: Tue, 21 Jul 1998 00:00
21 lines
1520 bytes
Please, help me!!!!
I have a DBF table with some fields. I have created an expression index
in this way:
  myTable.AddIndex('myIndex','Field1+Field2+dtos(Field3)',[ixExpression,
ixDescending])

I have to do a partial search on Field1 and Field2.
So I do the following:

  myTable.IndexKey:='myIndex';
  myTable.SetKey;
  myTable.KeyfieldCount:=1; { to use Field1 and Field2 }
  myTable.FieldByName('Field1').AsString:='aaaaaa';
  myTable.FieldByName('Field2').AsString:='bbbbb';
  myTable.GotoKey;

but this source doesn't work. I have tried also with GotoNearest.
Partial search doesn't work with expression indexes???
Please, tell me not!!!!!!!!!!
Please help me and, however, thanks for your interesting.
Thanks once again.
Re: Problem with partial search. Please help me!!!!
#92
Author: Richard Carter
Date: Tue, 21 Jul 1998 00:00
12 lines
1412 bytes
Gabriele Cardinali (febeaweb@febea.it) wrote:
: Partial search doesn't work with expression indexes???
: Please, tell me not!!!!!!!!!!

Sorry, but it doesn't.  I recall reading a work-around in the
Lloyd's Delphi help file, a Windows help file full of useful
information, which is available from http://www.inprise.com/
and a number of other websites.
--
============================================================
Rick Carter   carterrk@email.uc.edu   rcarter@tso.cin.ix.net
============================================================
Re: Problem with partial search. Please help me!!!!
#93
Author: David M. Goncalves
Date: Tue, 21 Jul 1998 00:00
56 lines
2660 bytes
Your example shows keyfield count as ONE. Could that be your problem?
You are searching on 2 fields, no? I suspect keyfieldcount will not work
anyway, because Delphi is stupid when it comes to expression indexes. 
It doesn't know which fields are in the expression, or probably how many
fields are in it.

Furthermore, I don't know what "TTable.IndexKey" is. I use dBASE
expression indexes all the time, and have never encountered that. 
IndexName, yes.

Try this, instead:

with mytable do
begin
  Setkey;
  Fieldbyname('FIELD1').asstring:=key1;
  Fieldbyname('FIELD2').asstring:=key2;
  Fieldbyname('FIELD3').asstring:='';
  Gotonearest;
  if (Fieldbyname('FIELD1').asstring<>key1)
  and (Fieldbyname('FIELD2').asstring<>key2)
  then showmessage ('BARF!');
end;

PLUS, remember that your keys will be case-sensitive, unless your
expression specifies otherwise, with the UPPER function! This could be
your problem, too...

Let me know how it goes...

DMGoncalves


Gabriele Cardinali wrote:
> 
> Please, help me!!!!
> I have a DBF table with some fields. I have created an expression index
> in this way:
>   myTable.AddIndex('myIndex','Field1+Field2+dtos(Field3)',[ixExpression,
> ixDescending])
> 
> I have to do a partial search on Field1 and Field2.
> So I do the following:
> 
>   myTable.IndexKey:='myIndex';
>   myTable.SetKey;
>   myTable.KeyfieldCount:=1; { to use Field1 and Field2 }
>   myTable.FieldByName('Field1').AsString:='aaaaaa';
>   myTable.FieldByName('Field2').AsString:='bbbbb';
>   myTable.GotoKey;
> 
> but this source doesn't work. I have tried also with GotoNearest.
> Partial search doesn't work with expression indexes???
> Please, tell me not!!!!!!!!!!
> Please help me and, however, thanks for your interesting.
> Thanks once again.
Re: Problem with partial search. Please help me!!!!
#91
Author: William Wester
Date: Fri, 24 Jul 1998 00:00
36 lines
1763 bytes
I've done partial searches a lot using DBF files with no trouble.
See notes below.

bill wester



On Tue, 21 Jul 1998 17:24:46 +0200, Gabriele Cardinali
<febeaweb@febea.it> wrote:

>Please, help me!!!!
>I have a DBF table with some fields. I have created an expression index
>in this way:
>  myTable.AddIndex('myIndex','Field1+Field2+dtos(Field3)',[ixExpression,
>ixDescending])
>
>I have to do a partial search on Field1 and Field2.
>So I do the following:
>
>  myTable.IndexKey:='myIndex';
>  myTable.SetKey;
cut{>  myTable.KeyfieldCount:=1; { to use Field1 and Field2 }}
>  myTable.FieldByName('Field1').AsString:='aaaaaa';
>  myTable.FieldByName('Field2').AsString:='bbbbb';
cut{>  myTable.GotoKey;}
    myTable.GoToNearest;        --> always works for me.
				I have never used KeyfieldCount

>
>but this source doesn't work. I have tried also with GotoNearest.
>Partial search doesn't work with expression indexes???
>Please, tell me not!!!!!!!!!!
>Please help me and, however, thanks for your interesting.
>Thanks once again.
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads