Solved

dBASE - Expression index (how to create)

Posted on 1998-05-14
7
499 Views
Last Modified: 2008-02-01
Hi all,

I have used a dBASE expression index many times.  You just create it using DBDesktop.. No sweat.

I want to create one programmatically now.  On the surface it would seem pretty easy:

  WITH FieldDefs DO BEGIN     {create the fields}
     Add( 'CENTER', ftString, 6, FALSE );
     Add( 'POSITION', ftString, 4, FALSE );
     Add( 'NAME', ftString, 4, FALSE );
     END;
  WITH IndexDefs DO BEGIN    {create the indexes}
     Add( 'IDX_CENTER', 'CENTER', [] );
     Add( 'IDX_POS', 'POSITION', [] );
     Add( 'IDX_BOTH', 'CENTER+POSITION', [ixExpression] );
     END;

The 'Idx_Both' index should be created as an expression index, however it croaks as being invalid when I run.  I can create the identical index in DBDesktop and it works just fine.  The first two indexes work of course.

This must be some kind of syntax error in specifying the index.  So, what am I doing wrong.

Ian C.

PS:  Yeh I know, no such word as indexes (indecies?)
0
Comment
Question by:icampbe1
  • 4
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
jturpin earned 100 total points
ID: 1345719
If you are using a TTable component simply say:

YourTable.AddIndex(TmpRepDX,
   'YourField1+YourField2+YourField3',[ixExpression]);

John.
0
 
LVL 2

Author Comment

by:icampbe1
ID: 1345720
Hi John,

Thanks for taking the time.  What's the difference between using the 'add' method of IndexDefs and unsing the AddIndex method of the TTable object?

 As my question shows, I use IndexDefs.Add successfully for all non-expression indexes.  Does TTable.AddIndex work the same for non-expression indexes as it does for expression indexes?  Will the index be permanent (in the underlying table definition)?

It is still a bit cloudy to me.  I'll be happy to give you full grades if you can help clarify this for me.

Cheers,
Ian C.
0
 
LVL 1

Expert Comment

by:jturpin
ID: 1345721
I am not sure if there is any difference between
the two. Maybe TTable.AddIndex does some additional
processing before it calls IndexDefs.Add

Yes, TTable.AddIndex works the same for non-expression
indexes as it does for expression indexes.

Yes, the index is permanent (in the underlying table
     definition)?

I hope this helps.

John.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:icampbe1
ID: 1345722
OK John,  There is a difference that I found.  It seems that the AddIndex method requires that the table must already exist.  The  Fieldefs.Add is used to build the original structure.  It would seem to me that they should both be the same.  Anyhow, thats the difference.  Thanks for your help.

Ian C.

PS:  Do you know how to create a dBASE 'Filter Index'?  I don't know where that would be done.
(iancamp@interlog.com)

0
 
LVL 1

Expert Comment

by:jturpin
ID: 1345723
When I need a subset of a dataset, I
usually clone the table and append the
records I need into the clone. Then
I process the much smaller clone set.
Works kind of like SQL.

John.
0
 
LVL 2

Author Comment

by:icampbe1
ID: 1345724
I've done that as well.  I'm curious, do you know how I can create a dBASE filter type of index?  Once again, I can do it with DBDesktop but can't do it with a TTable.   Just wondering.
Ian

0
 
LVL 1

Expert Comment

by:jturpin
ID: 1345725
No I don't. But I will look around.

John.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now