Monday, 23 May 2022

VFP Extract DBF Field structure to DBF File | Save Dbf Field Structure to Dbf vfp





DbfStru.Dbf

PARAMETERS DbfVal
**** Pass DBF name only, without extension.
CLOSE TABLES ALL 

IF  FILE("&DbfVal"+".dbf") = .T.
SELECT 0
USE "&DbfVal" ALIAS db
gnFieldCount = AFIELDS(gaFieldsArray)
SELECT 0
USE DbfStru  EXCLUSIVE
DELETE FOR DbfName = DbfVal
PACK 
mFieldName = ""
mFieldType = ""
mFieldSize = ""
FOR nCount = 1 TO gnFieldCount 
SELECT db
mFieldName = gaFieldsArray(nCount,1)
mFieldType = TYPE(mFieldName)
mFieldSize = FSIZE(mFieldName)


SELECT DbfStru
APPEND BLANK
Replace DbfName WITH DbfVal
Replace FieldName WITH mFieldName
Replace FieldType WITH mFieldType
Replace FieldSize WITH mFieldsize

ENDFOR 


RETURN DbfVal+" Structure Generated Successfully."
ELSE
RETURN DbfVal+" Not Found."
ENDIF 

No comments:

Post a Comment

Please, Write your valuable comments..