Kbase 12259: dBASE, Clipper, FoxBASE/Pro: How to convert .dbf to .d
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
dBASE, Clipper, FoxBASE/Pro: How to convert .dbf to .d
This notebook entry describes how database files in Xbase can be
be exported into a data file which can be processed by PROGRESS with
the Data Dictionary, bulk loader, or IMPORT statement.
Important: Data definitions in PROGRESS must correspond to the
structure in the Xbase file. PROGRESS does not support "memo" fields
directly. For example, a PROGRESS procedure cannot handle fields
larger than 3000 characters.
The following program was tested in FoxBASE Plus & Clipper 5.01a.
The program should run without problems in dBASE III, IV, FoxPro and
other dialects of Xbase without modifications. It is also listed in
the PROGRESS On-line! Bulletin Board under <U>pload/<D>ownload ->
DOS -> DBF2D.PRG for file name.
PRIVATE z1, z2, z3, z4, z5, z6, z7
* Mem Vars are named to avoid conflicts with field names.
* z1: File name with .dbf
* z2: Counter for fields
* z3: Field Name
* z4: Number of fields
* z5: Field Type
* z6: Export file .d
* z7: Number of records exported
SET TALK OFF
z1 = SPACE(20)
@0,0 CLEAR
@10,06 SAY 'Enter dBASE file name (without .dbf): ' GET z1
READ
z1 = TRIM(z1)
IF .NOT. FILE(z1 + ".dbf")
@18,12 SAY 'File not found.'
RETURN
ENDIF
USE &z1
z4 = FCOUNT()
z6 = z1 + ".d"
SET PRINTER TO &z6
SET PRINT ON
z7 = 0
DO WHILE .NOT. EOF()
z7 = z7 + 1
z2 = 0
DO WHILE z2 < z4
z2 = z2 + 1
IF z2 > 1
??' '
ENDIF
z3 = FIELD(z2)
z5 = TYPE(z3)
DO CASE
CASE z5 = 'C'
??'"' + TRIM(&z3) +'"'
CASE z5 = 'L'
??IIF(&z3, 'yes', 'no')
CASE z5 $ 'ND'
?? &z3
ENDCASE
ENDDO
?
SKIP
ENDDO
SET PRINT OFF
SET PRINT TO
CLOSE DATA
?'Number of records exported to '+z6+':', z7
RETURN
Progress Software Technical Support Note # 12259