Memowrite - ESC character

Post Reply
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Memowrite - ESC character

Post by Otto »

Copying dbf-files with memoread/memowrit adds a chr(26) (ESC character) at the end of the file.
Could this cause problems?
How can I add this C function to my FWPPC program?

Thanks in advance
Otto


Code: Select all

#pragma BEGINDUMP

#include <hbapi.h>
#include <hbapiitm.h>
#include "hbapifs.h"

HB_FUNC( MEMOWRIT )
{
PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pString = hb_param( 2, HB_IT_STRING );
BOOL bWriteEof = TRUE; /* write Eof !, by default is .T. */
BOOL bRetVal = FALSE;

   if( hb_parinfo(0) == 3                       && ISLOG( 3 ) )
bWriteEof = hb_parl( 3 );

   if( pFileName                                && pString )
{
FHANDLE fhnd = hb_fsCreate( ( BYTE * ) hb_itemGetCPtr( pFileName ), FC_NORMAL );

   if( fhnd != FS_ERROR )
{
ULONG ulSize = hb_itemGetCLen( pString );

   bRetVal = ( hb_fsWriteLarge( fhnd, ( BYTE * ) hb_itemGetCPtr( pString ), ulSize ) == ulSize );

/* NOTE: CA-Clipper will add the EOF even if the write failed. [vszakats] */
/* NOTE: CA-Clipper will not return .F. when the EOF could not be written. [vszakats] */
#if ! defined(OS_UNIX_COMPATIBLE)
{
if( bWriteEof ) /* if true, then write EOF */
{
BYTE byEOF = HB_CHAR_EOF;

   hb_fsWrite( fhnd, &byEOF, sizeof( BYTE ) );
   }
}
#endif

hb_fsClose( fhnd );
   }
}

hb_retl( bRetVal );
   }

#pragma ENDDUMP

//----------------------------------------------------------------------------//
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

>
Copying dbf-files with memoread/memowrit adds a chr(26) (ESC character) at the end of the file. Could this cause problems?
>

We have never tried it. Please try it and let us know if it works, thanks

> How can I add this C function to my FWPPC program?

Just add that code that you have published to your PRG :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Thank you, Antonio.

The dbf-files seems to work also with the ESC but to face no problems in future I prefer to copy without.

If I link the code I get following warnings:

c:\develop8\nextstb\mystb.c(13285) : warning C4129: 'd' : unrecognized character escape sequence
c:\develop8\nextstb\mystb.c(13285) : warning C4129: 'm' : unrecognized character escape sequence
* Application successfully built and all is working.

Regards,
Otto
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

Those warnings are caused as Harbour output .C files use "\" for paths, though "\\" should be used.

You can safely ignore them.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply