Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
FREE TABLE
No one can be perfectly free till all are free.
—Herbert Spencer, Social Statics, 1851
This command is designed to save your skin. If you’ve somehow lost a database (accidentally deleted it, trashed it, or something), it lets you rescue the poor trapped tables within.
FREE TABLE TableName
When you add a table to a database, a backlink is added to the table header, pointing at the database (see “ DBF, FPT, CDX, DBC—Hike!” for more on this). This is why you can open a table in a database and have the database open up, too. (Of course, it’s also one of the primary reasons Visual FoxPro tables aren’t backward-compatible.)
If the database can’t be found, Visual FoxPro has a quandary. FREE TABLE
is the solution to that puzzle. It clears the backlink and turns the table back into a “FREE TABLE
” once again. Don’t confuse this command with REMOVE TABLE
—that’s the one to use for taking a table out of a healthy database. FREE TABLE
is for emergencies.
The help for FREE TABLE
contains dire warnings about what happens if you free a table and the database is still around. Actually, Visual FoxPro seems to handle this pretty well, offering to re-create the backlink when you try to access the table from within the database. You can, of course, confuse the heck out of FoxPro if you add the table to another database, then try to access it from the first. Each time you try to access it from the one that doesn’t own it at the moment, you get prompted to create the backlink. Shades of infinite loops.
The interface also handles the case of a table whose database can’t be found. You’re prompted to free the table. Since we don’t see any of this as the sort of thing you’d put in an application, you may rarely need this command—most of the time, you’ll handle these problems through the interface. FREE TABLE
will be reserved for times when you have a whole bunch of enslaved tables to emancipate.
FREE TABLE MyTable