dBASE - Expression index (how to create)

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 );
  WITH IndexDefs DO BEGIN    {create the indexes}
     Add( 'IDX_CENTER', 'CENTER', [] );
     Add( 'IDX_POS', 'POSITION', [] );
     Add( 'IDX_BOTH', 'CENTER+POSITION', [ixExpression] );

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?)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you are using a TTable component simply say:



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
icampbe1Author Commented:
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.

Ian C.
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

I hope this helps.

Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

icampbe1Author Commented:
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.

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.

icampbe1Author Commented:
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.

No I don't. But I will look around.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.