How to open a dbf with memo (.fpt) missing

How to open a dbf with memo (.fpt) missing

Postby gkuhnert » Wed Nov 30, 2011 10:50 am

Hello all,

how do I open an dbf file if the according memofile (.ftp) is missing (without prompting an error)?

Thanks in advance for your help
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: How to open a dbf with memo (.fpt) missing

Postby Enrico Maria Giordano » Wed Nov 30, 2011 11:28 am

I don't think you can open it. If you just want to trap the error then you can use a TRY/CATCH structure.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to open a dbf with memo (.fpt) missing

Postby ukoenig » Wed Nov 30, 2011 11:34 am

Change the 1. Byte ( Format-info ) from the DBF with a Hexeditor :
This sample shows => F5 = Foxpro with Memo
to open without Memo change the Byte to => 03 or try another Value from the Filetype-table

Download a free Hexeditor :
http://www.chmaas.handshake.de/

Image

Because of a missing Memo-file, it is impossible, to open the Dbf :

Image

Patching the 1. Byte, now it is possible, to open the DBF with the Editor.
( tested / changed F5 to Value 30 of Visual Foxpro )
Delete the Memo-field and save the DBF.

opened Dbf without the Fpt-file :

Image

Best Regards
Uwe :lol:
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: How to open a dbf with memo (.fpt) missing

Postby gkuhnert » Fri Dec 02, 2011 7:36 am

@Uwe, Enrico: Thanks a lot.
I was hoping to be able to resolve this issue programmatically, like Visual dBase offers also to open the file without blob.
But in this case we'll have to handle the issue manually.
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Re: How to open a dbf with memo (.fpt) missing

Postby StefanHaupt » Fri Dec 02, 2011 3:49 pm

Gilbert,

you can do it programmatically, just open the dbf with the low level functions fopen, fread, etc. Change the first bye and close the file.

Code: Select all  Expand view
// The example implements a user-defined function that reads the
// entire contents of a file into a memory variable using
// low-level file functions:

   #include "FileIO.ch"

   PROCEDURE Main
      LOCAL cFile := "test.dbf" //"MyFile.txt"
      LOCAL cStream

      IF .NOT. ReadStream( cFile, @cStream )
         IF FError() <> 0
            ? "Error reading file:", FError()
         ELSE
            ? "File is empty"
         ENDIF
      ELSE
         ? "Successfully read", Len(cStream), "bytes"
      ENDIF
   RETURN

   FUNCTION ReadStream( cFile, cStream )
      LOCAL nFileHandle := FOpen( cFile )
      LOCAL nFileSize

      IF FError() <> 0
         RETURN .F.
      ENDIF

      nFileSize := FSeek( nFileHandle, 0, FS_END )
      cStream   := Space( nFileSize )
      FSeek( nFileHandle, 0, FS_SET )
      FRead( nFileHandle, @cStream, nFileSize )
      FClose( nFileHandle )
   RETURN ( FError() == 0 .AND. .NOT. Empty( cStream ) )
 
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 101 guests