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

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

Postby ukoenig » Mon Mar 16, 2015 7:20 pm

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 :?:
Last edited by ukoenig on Mon Mar 16, 2015 7:41 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby Rick Lipkin » Mon Mar 16, 2015 7:38 pm

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
User avatar
Rick Lipkin
 
Posts: 2636
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

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

Postby ukoenig » Mon Mar 16, 2015 7:47 pm

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 :(
Last edited by ukoenig on Mon Mar 16, 2015 8:04 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby Richard Chidiak » Mon Mar 16, 2015 8:03 pm

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

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

Postby ukoenig » Mon Mar 16, 2015 9:00 pm

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 :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby nageswaragunupudi » Mon Mar 16, 2015 9:20 pm

Code: Select all  Expand view

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  Expand view
#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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

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

Postby ukoenig » Mon Mar 16, 2015 10:37 pm

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
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests