Solved

dBASE - Expression index (how to create)

Posted on 1998-05-14
7
507 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 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