Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Info on a free table
Message
De
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:
00672357
Vues:
7
This message has been marked as the solution to the initial question of the thread.
>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
Ç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