FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour DBF - convert from old clipper ( DBT ) to FPT / CDX
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: Mon Mar 16, 2015 07: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 :-)
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.
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: Mon Mar 16, 2015 07: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

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: Mon Mar 16, 2015 07: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 :-)
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.
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: Mon Mar 16, 2015 08:03 PM

Uwe

try something like this

  USE (DNTX) VIA &quot;DBFNTX&quot; NEW SHARED
  aADBF  := (DNTX)-&gt;(DBSTRUCT())
  DBCREATE(FUSER,AADBF,&quot;DBFCDX&quot;)
  USE (FUSER) VIA &quot;DBFCDX&quot; NEW SHARED

then convert from one to other

Hth

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: Mon Mar 16, 2015 09:00 PM
Richard,

thank You very much.

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

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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: Mon Mar 16, 2015 09:20 PM
Code (fw): Select all Collapse
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 (fw): Select all Collapse
#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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: DBF - convert from old clipper ( DBT ) to FPT / CDX
Posted: 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.

Continue the discussion