Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Info on a free table
Message
 
À
26/06/2002 05:15:17
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00672345
Message ID:
00672394
Vues:
8
>>Hi there,
>>
>>Is it possible to get the number of fields and the total field length (as displayed on the table tab when modifying a table) from a free table. If so can this be done without actually having to open the table?
>>
>>Thanks in advance
>>Caroline
>
>Caroline,
>If you could open the table built-in functions provide an easier way to get what you want like afields. However you could do as well w/o actually opening it provided you can access it for read (not opened excl elsewhere) :
>
>
>function FcountAndRecSize
>Lparameters tcDBF
>Local handle, lnFileSize, lnReccount, lnHeaderSize, lnRecordSize, ;
>	lnCalculatedReccount, llHasMemo
>handle=fopen(tcDBF) && Opened for read
>* Read header info
>lnHeaderSize = ReadBytes(handle, 8,2)
>lnRecordSize = ReadBytes(handle,10,2)
>lnFieldCount = (lnHeaderSize - (263+32+1))/32
>=fclose(handle)
>? lnFieldCount, lnRecordSize
>
>function ReadBytes
>Lparameters tnHandle, tnPos, tnSize, tlLR
>Local lcString, lnRetValue,ix
>=fseek(tnHandle, tnPos,0) && Go to Pos
>lcString = fread(tnHandle, tnSize) && Read tnSize bytes
>lnRetValue = 0
>For ix=0 to tnSize-1  && Convert to a number
>	lnRetValue = lnRetValue + asc(substr(lcString,ix+1)) * ;
>		iif(tlLR,256^(tnSize-1-ix),256^ix)
>Endfor
>Return int(lnRetValue)
>
Cetin

Thanks Cetin that was exactly what I was looking for.
Caroline
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform