Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple USE commands

Status
Not open for further replies.

HowardHammerman

Instructor
Oct 11, 2001
640
US
I need to open the same table two times.
The first time I will open it with one index.
the second time with another.
******************************
sele c
use in_res index in-rnum.idx shared
sele a
use in_res index in-date.idx shared again
**************************************
the problem is that FoxPro retains the second index association and not the first in both work areas.

Any help would be appreciated.
By the way, I know that my coding is old fashioned. Help on that would also be appeciated.


Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
I haven't used IDX files in quite a spell, so I'm not sure if that's normal behavior or not.

I would recommend you take a look at using compound indexes instead of stand alone though.
Those are basically one index file containing all the index tag/keys/orders you could need. You don't have to explicitly open them as they are opened and updated automatically when the tables are USEd.
Also, you can issue a USE AGAIN ... with compound indexes and retain the order you requested when you switch between desired work areas.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
try using the same table with two different alias names.

Code:
sele c
use in_res index in-rnum.idx shared alias in_res
sele a
use in_res index in-date.idx shared alias in_res2 again

Bye, Olaf.
 
Dave, it is not my database and I can't change the structure.
Olaf, the problem with you approach is that in_res2 will have an index by in_res will not.

I found that the following works:
sele a
use in_res index in-date.idx, in-rnum.idx
sele b
use in_res again
sele a
set order to 1
sele b
set order to 2

Thanks,

Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
If you are using the OLD IDX indices, then are you using one of the non-Visual Foxpro versions?

If not, then my apologies.

But if so, for the most appropriate replies your question should be posted to Microsoft: FoxPro (old versions 1 to 2.6) Forum forum182

This forum is for Microsoft: VFP - General Coding Issues Forum[/B]

Good Luck,
JRB-Bldr
 
I am using visual foxpro, I am just using it in an old way because my client insists on using the old *.dbf and *.idx files.

lol.

Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
If I recall correctly, the issue is that when you open one IDX, it closes any other, unless you do it right. It's a long time since I used IDX files, so I can't be sure. You might want to tell your client that IDX files are about 20 years out of date.

Tamar
 
I just had to see what happens, so I did a little test.
This works I believe, as HowardHammerman would like it to:
Code:
use customer excl
index on custname to custname
index on custnumber to custnum
index on mapname to mapname
Of course, master index at this time is 'mapname'. Now if I issue a:
Code:
select 0
use customer again alias fred
Of course the table is reused in a new work area as 'fred', and after doing a 'display status', the same index files are already open for 'fred' as for 'customer', but with no order set.
So if I issue this command with 'fred' selected:
Code:
set order to custnum
A 'list status' looks like this:
Code:
Select area:  1, Table in Use: C:\FOXPROW\CUSTOMER.DBF    Alias: CUSTOMER
    Master index file:   C:\FOXPROW\CUSTNAME.IDX
                                           Key: CUSTNAME
           Index file:   C:\FOXPROW\CUSTNUM.IDX
                                           Key: CUSTNUMBER
           Index file:   C:\FOXPROW\MAPNAME.IDX
                                           Key: MAPNAME
            Memo file:   C:\FOXPROW\CUSTOMER.FPT
       Lock(s): Exclusive USE

Currently Selected Table:
Select area:  2, Table in Use: C:\FOXPROW\CUSTOMER.DBF    Alias: FRED
           Index file:   C:\FOXPROW\CUSTNAME.IDX
                                           Key: CUSTNAME
    Master index file:   C:\FOXPROW\CUSTNUM.IDX
                                           Key: CUSTNUMBER
           Index file:   C:\FOXPROW\MAPNAME.IDX
                                           Key: MAPNAME
            Memo file:   C:\FOXPROW\CUSTOMER.FPT
       Lock(s): Exclusive USE
Note that the order for customer is still 'custname'.
This worked the same way in FoxPro 2.x and in VFP 9.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I suppose this is just a summery of what has been said on said differently

use in_res index in-date.idx, in-rnum.idx in A order in-date alias in_res1

use in_res again index in-date.idx, in-rnum.idx in B order in-rnum alias in_res2

You can set the workarea in the use so you can eliminate the step of doing the "select A" before calling the use
secondly you can issue an "order" in the use eliminating the "set order to"

lastly adding the "again" in the second command instructs fox that you want a complete new instance on the table

I want to also point out that in the code you were using you are only opening the index needed for each table and just want to issue a note that if you would change the data in either table on an indexed field you will create an instance where the index could become "out of sync" and produce an error.


Steve Bowman
Independent Technology, Inc.
CA, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top