Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yahya Abou dalal
  Where is Yahya Abou dalal?
 tripoli
 Lebanon
 Yahya Abou dalal
 To: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 Tags
Subject: RE: indexes order change in cdx
Thread ID: 209254 Message ID: 209342 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Saturday, December 27, 2008 2:19:41 PM         
   


thank you

> > I have an old lookup routine (called from get valid ) whick open a browse window of a table ordered by code of an item or it's name.the routine pass 1 for code and 2 for name as the order to be set.now this routine don't work as expected because the order of indexes is changed when I upgraded my application to vfp(don't know why),so order 1 is not for code and 2 is not for name.
> > the routine is called like this:
> > @ x,y say '.......' get mvar valid P_SEEK(mphys,"phys",1,"mphys","code","name1",4,28,4,40)
> > the first 1 in parameters is the order
> > I used this routine extensivly in my application and don't want to rewrite everything
> > So if I can rearrange my indexes so bycode is 1 and byname is 2 my routine works perfectly
> > thanks
>
> I think the only reliable way you can do this is to drop the indexes completely and re-create them in the specific order. Just use code like this:
>
>
USE [table] EXCLUSIVE
> DELETE TAG ALL
> INDEX ON code TAG ByCode
> INDEX ON name TAG ByName

>
> And this is a perfect example of why you should not use magic numbers in code - because things can change. A much better solution would have been to use the number passed to look up the NAME of the index tag to use in a metadata table (maybe as simple as three columns for "TableName", "IndexID" and "IndexName" ). Then if the order changed all you have to do is change the metadata table so that the number points to the correct index.
>
> Regards
> Andy Kramek
> Microsoft MVP (Visual FoxPro)
> Tightline Computers Inc, Akron Ohio, USA

ENTIRE THREAD

indexes order change in cdx Posted by YAHIA ABOUDALAL @ 12/26/2008 12:37:22 PM
RE: indexes order change in cdx Posted by tushar @ 12/26/2008 1:03:21 PM
RE: indexes order change in cdx Posted by Stefan Wuebbe @ 12/26/2008 1:06:23 PM
RE: indexes order change in cdx Posted by YAHIA ABOUDALAL @ 12/26/2008 2:48:33 PM
RE: indexes order change in cdx Posted by Andy Kramek @ 12/26/2008 3:21:33 PM
RE: indexes order change in cdx Posted by YAHIA ABOUDALAL @ 12/27/2008 2:19:41 PM
RE: indexes order change in cdx Posted by tushar @ 12/26/2008 4:18:36 PM