Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is a table part of a dbc? How to??
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00554114
Message ID:
00581845
Views:
33
This message has been marked as the solution to the initial question of the thread.
LPARAMETERS tcTableFullName
LOCAL lcDbcFullName, lcB1, lcB2, lnOffset, lcBuffer
lnFh1 = FOPEN(tcTableFullName)
* Make sure that's VFP table
lcBuffer = FREAD(lnFh1, 1)
IF ASC(lcBuffer) <> 0x30
  * not VFP table
  lcDbcName = "***NOT VFP TABLE***"
  RETURN lcDbcName 
ENDIF
* Position of the first data record - 2 bytes
= FSEEK(lnFh1, 8, 0)
lcB1 = FREAD(lnFh1,1)
lcB2 = FREAD(lnFh1,1)
* Offset to the beginning of the DBC name 
lnOffset = ASC(lcB2) * 256 + ASC(lcB1) - 263
= FSEEK(lnFh1, lnOffset, 0)
* The DBC name or 0x00's if it's free table
lcBuffer = FREAD(lnFh1, 263)
IF ASC(lcBuffer) = 0
  * free table
  lcDbcName = "***FREE TABLE***"
ELSE
  * table in dbc
  lcDbcName = LEFT( lcBuffer, AT( CHR(0), lcBuffer) - 1)
ENDIF
= FCLOSE(lnFh1)

RETURN lcDbcName 
>Sergey,
>
>I need to know database name without opening the table. How this program should be modified to return database name?
< snip >
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform