Solved

dBASE - Expression index (how to create)

Posted on 1998-05-14
7
509 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 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