FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC Memowrite - ESC character
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Memowrite - ESC character
Posted: Thu Nov 20, 2008 10:31 AM
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



#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

//----------------------------------------------------------------------------//
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Memowrite - ESC character
Posted: Thu Nov 20, 2008 10:37 AM

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
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Memowrite - ESC character
Posted: Thu Nov 20, 2008 01:57 PM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Memowrite - ESC character
Posted: Thu Nov 20, 2008 02:09 PM

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

Continue the discussion