Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Table header question
Message
De
23/09/2004 05:49:56
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00945261
Message ID:
00945291
Vues:
18
>Folks
>
>In various discussions, e.g. at http://fox.wikis.com/wc.dll?Wiki~NotATable, and in the VFP help file, information is given regarding the structure of table headers.
>
>I am led to understand that the file size for any table is calculated as (RECORDLENGTH * RECORDS) + HEADERSIZE. The position of the first data record is stored at byte offset 8-9 so that, since the header starts at byte zero, this is the same as the header size in bytes.
>
>The thing is, when I actually do the above sum for my tables sometimes the answer is the same as and sometimes it is one byte less than the file size returned by FSEEK(lnHandle, 0, 2) when opening the table as a file for this purpose.
>
>The formula for the actual number of records in a table is given in two versions in the Fox Wiki discussions:
>
>lnCalculatedReccount = (lnFileSize-(lnFirstRecPos+1))/lnRecordSize
>lnCalculatedReccount = FLOOR((lnFileSize-(lnFirstRecPos+1))/lnRecordSize)
>
>I want to repair damage to my headers, so which answer is correct? Is FSEEK the best way to get the exact file size in bytes?
>
>Thanks
>John Burton

John,
Floor() one is the correct one. However +1 there was related with Fox2x tables. Since now everyone assumes and uses VFP tables I edited code on wiki site and dropped it. Thanks for reminding.
lnCalculatedReccount = FLOOR((lnFileSize-lnFirstRecPos)/lnRecordSize)

Floor is necessary because sometimes table is off by one record due to incomplete record at end (ie: recsize=100 but last record lenght is say 70). VFP might not say anything on that situation but it's an error IMHO.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform