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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'USE' command

Status
Not open for further replies.

KDavie

Programmer
Feb 10, 2004
441
US
Okay, here is another total newbie question:

After I am done with a table that I opened using the 'use' command, do I need to close it? If so, what is the command?

Thanks in advance for your help.

-Kevin
 
Kevin,

It is not essential to close the table, as it will be closed automatically when the application terminates. However, many programmers like to close tables as soon as they finish using them -- I guess they like being tidy (and there is also a small risk that if the application crashes while the table is open, the table or its indexes could become corrupted).

If you do decide to close the table explicitly, Chris's code will do it for you.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Another option.

SELECT myTable
USE


The use by itself will close the current work area.

To add to what Mike said, I usually open my main system table(s) right off that bat and take any io hit them. I leave them open unless I need to use them exclusively later.

I open and close support tables, that are unique to a specific routine, as the routine is accessed.

Open and closing tables is one of the slowest VFP operations so you don't want to do it a lot, but on the other hand you don't want a bunch of file handles open. It is a fine line you have to walk.



Jim Osieczonek
Delta Business Group, LLC
 
kevin,

i agree with the tipmasters. as for me, i usually close my tables using sir chris's code (USE IN TableAlias). it's easier to see which tables are closed and which are still open coz kinda confusing when you use several tables in different working areas at a single time.


kilroy [trooper]
philippines
"and that's what we call creativity..."
 
I personally use a tip that I got from MikeLewis some time back...

Use In Select("MyAlias")

...it always closes the correct alias, unless that alias isn't open in one of the work areas and then it won't even throw an error. It is the best way of doing this I've found so far. There are times however when you would want it to throw an error so you knew something was wrong I guess.

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Thanks for your help everyone, I appreciate it!

-Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top