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.
DBUSED()
This function tells you whether a specified database is open. It’s the equivalent of USED()
for database containers.
lInUse = DBUSED( cDatabase )
Unlike many other functions, this one doesn’t have a default result if you omit the parameter. Calling DBUSED()
without a parameter results in an error message.
DBUSED() incorrectly returns .F. if the database is open but isn't in the current directory and you specify an extension but no path (for example, "TESTDATA.DBC"). |
We haven’t found a whole lot of uses for this function. We suspect it’s more useful in developer tools, where you want to manipulate a particular database, than in client applications. One use in both situations, though, is to double-check that a particular database is still open before you try to SET DATABASE
TO it.
CLOSE ALL
CD HOME()
? DBUSED("TasTrade") && Returns .F.
OPEN DATA _SAMPLES + "TasTrade\Data\TasTrade"
? DBUSED("TasTrade") && Returns .T.
? DBUSED(DBC()) && Returns .T.
? DBUSED("TasTrade.DBC") && Returns .F. -- bug!
CLOSE DATA
USE Customer && Automatically opens database
? DBUSED("TasTrade") && Returns .T.