Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IsFreeTable()...
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00289757
Message ID:
00289802
Views:
28
>>>I have an application in development that distributes client-side data as an application with the master tables,the DBC and all data access methods and business rules compiled in the application.
>>>
>>>When an application object is created...
>>>
>>>loData = NEWOBJECT("Data_Space","Client_Data.App")
>>>
>>>two transaction tables are created as members of the DBC. If the tables already exist I want to validate they have not been freed from the DBC.
>>>
>>>Because the DBC is included inside the application file when I try to open the transaction table from outside of the object VFP prompts me to locate the DBC (can't be done - which is what I want) or delete the link (Free the Table - which I don't want).
>>>
>>>I want a method that verifies none of the tables in the DBC have been made free tables which will be called from the Init of the "Data_Space" object. The OpenDataBase method uses the arguments - EXCLUSIVE VALIDATE. The VALIDATE checks to see that tables and indexes referenced in the database are available on disk. VFP also checks to see that referenced fields and index tags exist in the tables and indexes. It doesn't check to see if any of the tables have been made free.
>>>
>>>I am looking for a IsFreeTable function that reads the header of the table. I believe the RECCOUNT(), RECSIZE() and FSIZE() retrieve this information from the header?
>>>
>>>Any ideas are appreciated.
>>>
>>>Thanks,
>>Hi Bill,
>>
>>Will
>>lcdbc = CURSORGETPROP('Database')
>>llisfree = EMPTY(lcdbc)
work?
>
>Actually, this will only work after opening the table, which I think is what he istrying to avoid.
>
>William, you can get this information from the dbf file by opening it with low level functions, and checking the value of the right byte. Unfortunately, the dbc location comes after the field records, so its location varies depending on how many fields the table has. But here's how to calculate what byte to look at:
>
>31 + 32*nFields + 2
>
>So if your table has 10 fields, your dbc location (or lack of) can be found beginning at byte 31+320+2, or 353. If the table is free, Byte 354 will contain a 0 (0x00) otherwise it will contain the relative path to the database.
>
>lhFile = FOPEN("C:\table1.dbf")
>=FSEEK(lhFile, 353)
>ldFreeByte = FREAD(lhFile, 1)
>
>IF ASC(ldFreeByte) = 0
>* Table is Free
>ENDIF

Hi Erik (and I'm forwarding this to Ed too, you suggested something similar),

The only problem I have with this method as opposed to the other one is the overhead involved (compared to my solution). In reality, either way you're "opening" the table. In my case it's a high level access, as opposed to low level here.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform