
Global   FieldNames[100]
Global   FieldTypes[100]
Global   FieldLengths[100]

Global DbFields()
Global FileName

FileName = Upper(Ask("Enter FileName:"))
quiet off
DbFields()

Function DbFields()
 Local NumOfFields Ctr
 Local BinHeader BinNumOfFields BinDummy
 Local  BinFieldLength   BinFieldOffset   BinFieldType   BinFieldName
 Local  FieldLength   FieldOffset   FieldType   FieldName
 Local mydata BinData locat
 Local BinRecNum
 Local Recs[4]
 Local TotalRecs

  BUFFER BinRecNum         SIZE 1
  BUFFER BinHeader         SIZE 2080
  BUFFER BinNumOfFields    SIZE 2
  BUFFER BinDummy          SIZE 22
  BUFFER BinData           SIZE 22

  BUFFER BinFieldLength    SIZE 2
  BUFFER BinFieldOffset    Size 2
  BUFFER BinFieldType      Size 2

  BUFFER BinFieldName      Size 22

clear recs[]

Fopen FileName as 1

    Fseek 1 2064
    For Ctr = 1 to 4
      Fread 1 Binary 1 Into BinRecNum
      UnPack BinRecNum "B" Recs[Ctr]
    End For
    TotalRecs = Recs[1] + (256*Recs[2]) + (256^2*Recs[3]) + (256^3*Recs[4])
    Fseek 1 2080
    Fread 1 Binary 2 Into BinNumOfFields
    UnPack BinNumOfFields "B" NumOfFields
    Fread 1 Binary 22 Into BinDummy

For Ctr = 1 to NumOfFields
    Fread 1 Binary 2 Into BinFieldLength
    UnPack BinFieldLength "B" FieldLengths[Ctr]
    Fread 1 Binary 2 Into BinFieldOffset
    UnPack BinFieldLength "B" FieldOffset
    Fread 1 Binary 2 Into BinFieldType
    UnPack BinFieldType "B" FieldTypes[Ctr]
    Fread 1 Binary 22 Into BinFieldName
    UnPack BinFieldName "S" FieldNames[Ctr]
'    All = All & fieldname
End For

  locat = (2104+(98*NumOfFields))
  Fseek 1 locat+4+NumOfFields
For Ctr = 1 to TotalRecs
  Fread 1 Binary FieldLengths[ctr] Into BinData
  UnPack BinData "C" MyData
  message chr(mydata)
'  Fread 1 Binary FieldLengths[2] Into BinData
'  UnPack BinData "B" MyData
'  Fread 1 Binary 6 Into BinData
'  message FieldLengths[Ctr]

End For

fclose 1

End Function









