Page 1 of 1

DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 7:20 pm
by ukoenig
Hello,

I have to convert a old Clipper app
There is a old DBF-format ntx and dbt
as well the text is saved loaded using AnsitoOem / OemtoAnsi

After my fist tests creating a temp.dbf from a structure-array
and append from the old data, I get a error :

Time from start: 0 hours 0 mins 9 secs
Error occurred at: 16.03.2015, 20:01:43
Error description: Error DBFCDX/1012 Corruption detected

Next I have to recover the missing < ÄÖÜäöü >
it means scanning all fields and replacing the missing chars.
Text is saved like :
I_VAR[48] := OemToAnsi((10)->WAEHRG1)

Import / convert a old DBF

Fields
...
...
AADD(DBFARRAY, { "RECHNG_ART", "N", 1, 0 })
AADD(DBFARRAY, { "LFD_RECHNR", "N", 5, 0 })

creating a Temp-file

IF LEN(DBFARRAY) == 0
MsgInfo( "DBF Structure-Error", "New Structure" )
RETURN NIL
ENDIF
DELETE FILE ( c_Pfad3 + "TEMP.DBF" )
DBCREATE( c_Pfad3 + "TEMP.DBF", DBFARRAY, "DBFCDX", .T. )
USE ( c_Pfad3 + "TEMP.DBF" ) // FPT created

Append the old DBF

IF File( c_Pfad3 + "OLD.DBF" )
APPEND FROM ( c_Pfad3 + "OLD.DBF" )
DELETE FILE ( c_Pfad3 + "OLD.DBF" )
FRENAME( c_Pfad3 + "TEMP.DBF", c_Pfad3 + "NEW.DBF" )
FRENAME( c_Pfad3 + "TEMP.FPT", c_Pfad3 + "NEW.FPT" )
ENDIF

Maybe any existing solutions ?

best regards
Uwe :?:

Re: DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 7:38 pm
by Rick Lipkin
Uwe

Make sure you have the proper REQUEST for the database drivers at the top of your program

REQUEST DBFCDX
REQUEST DBFNTX
rddsetdefault ( "DBFCDX" )

Hope that works
Rick Lipkin

Re: DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 7:47 pm
by ukoenig
Rick,
thank You very much

only
REQUEST DBFNTX // added but NO difference
is not included

The error-part :

DBCREATE( c_Pfad3 + "TEMP.DBF", DBFARRAY, "DBFCDX", .T. ) // new empty DBF
USE ( c_Pfad3 + "TEMP.DBF" )
IF File( c_Pfad3 + "OLD.DBF" )
APPEND FROM ( c_Pfad3 + "OLD.DBF" ) // the error-line
same fields in TEMP.dbf and OLD.dbf !!!

defined at top

REQUEST DBFCDX
RDDSETDEFAULT ( "DBFCDX" )
SETBALLOON( .T. ) // Balloon shape required for tooltips

SET DATE GERMAN // Datum im deutschen Format (TT.MM.JJJJ)
SET EPOCH TO 1990
SET DATE FORMAT "DD.MM.YYYY"

SET SCOREBOARD OFF // Keine Meldungen in Zeile 0
SET SOFTSEEK ON // Fr Datenbank-Suchfunktionen
SET CENTURY ON // Jahr vierstellig: TT.MM.JJJJ
SET EXACT ON // Alt-D und Alt-C k”nnen Hotkeys se


best regards
Uwe :(

Re: DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 8:03 pm
by Richard Chidiak
Uwe

try something like this

USE (DNTX) VIA "DBFNTX" NEW SHARED
aADBF := (DNTX)->(DBSTRUCT())
DBCREATE(FUSER,AADBF,"DBFCDX")
USE (FUSER) VIA "DBFCDX" NEW SHARED

then convert from one to other

Hth

Richard

Re: DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 9:00 pm
by ukoenig
Richard,

thank You very much.

I tested my logic using another old DBF but WITHOUT memo-fields
NO error :roll:

It seems, the problem belongs to converting MEMO-fields

best regards
Uwe :?:

Re: DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 9:20 pm
by nageswaragunupudi

Code: Select all

REQUEST DBFCDX
...
...

SET DELETED OFF
USE OLD.DBF NEW VIA "DBFNTX"
COPY TO NEW.DBF VIA "DBFCDX"
 
For testing, copy this program to \fwh\samples folder.

Code: Select all

#include "fivewin.ch"

REQUEST DBFCDX

function main()

   SET DELETED OFF
   USE CLIENTS NEW VIA "DBFNTX"
   COPY TO CLIENTS2 VIA "DBFCDX"
   CLOSE DATA

   SET DELETED ON
   USE CLIENTS2 VIA "DBFCDX"
   XBROWSER "CLIENTS2" SETUP ( oBrw:Photo:cDataType := 'F' )
   CLOSE DATA

return nil
 
Build and run it either with buildh.bat or buildx.bat

Re: DBF - convert from old clipper ( DBT ) to FPT / CDX

Posted: Mon Mar 16, 2015 10:37 pm
by ukoenig
Mr. Rao

thank You very much

I converted one of the old DBF-files.
It works perfect and the memos are still ok with the original text.

best regards
Uwe :D