Hackers Guide to Visual FoxPro 7.0
Alias(), DBF(), Select(), Used()
These functions return an assortment of information about work areas and the tables in use in them. (Why does this sound like the promo for a trashy talk show? "Work areas and the tables that use them—next Geraldo!") Several of these functions have an optional parameter that can be either cAlias or nWork area. If either is passed, the function returns information about the table in use in the specified work area (the one where cAlias is the alias or the one numbered nWork area). When this parameter is omitted, these functions return information about the current work area.| Usage | cAliasUsed = ALIAS( [ cAlias | nWorkArea ] ) |
| Example | cInUse = ALIAS() |
| Usage | cFileName = DBF( [ cAlias | nWorkArea ] ) |
| Example | IF RIGHT(DBF(),3)="TMP" * it's a "real" cursor ELSE * it's a filter ENDIF |
| Usage | nWorkArea = SELECT( [ nDoWhat | cAlias ] ) |
| Parameter | Value | Meaning |
| nDoWhat | 0 | Return the number of the current work area. |
| Omitted | If cAlias is also omitted, return the number of the current work area. | |
| 1 | Return the number of the highest available work area. | |
| Anything else | Return 0. | |
| cAlias | Character | Return the number of the work area where cAlias is open. |
| Omitted | If nDoWhat is also omitted, return the number of the current work area. |
SELECT() is a somewhat confused function—it has three related, yet quite different meanings. It can tell you the number of the current work area, or the work area where a table is open, or it can find an unused work area for you.
The 0 value for nDoWhat is unnecessary; omitting the parameter altogether has the same result. SELECT(1) isn't all that useful anymore since SELECT 0 lets you find an available work area and USE ... IN 0 opens a table in an available area. We haven't found any reasons to want the highest rather than the lowest available work area—except, perhaps, to show off the 32,767 areas available in each data session. SELECT() is especially useful when you need to change work areas in a black-box function. You can save the current work area, go do what you need to, then restore the work area before leaving the function. Other than this, we don't have any use for SELECT(), since we don't want to know what work area a table uses.| Example | LOCAL nSelect * Save the work area nSelect=SELECT() * Now go to another SELECT 0 USE SomeTable * Do something USE * Return to original work area SELECT (nSelect) |
| Usage | lInUse = USED( [ cAlias | nWorkArea ] ) |
| Example | IF USED('lookups') SELECT lookups ELSE SELECT 0 USE lookups ENDIF |
| See Also | Alias, DBC(), DBUsed(), InDBC(), Select, Set Database, Set FullPath, Use |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории