Solved

dBASE - Expression index (how to create)

Posted on 1998-05-14
7
496 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

16 Experts available now in Live!

Get 1:1 Help Now