Migrating to Harbour

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

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

Antonio,

yes: too many differences for me:

Code: Select all

HB_FUNC( MEMOLINE )
{
   HB_MLC_INFO MLC;
   HB_ISIZ nLine = hb_parnsdef( 3, 1 );
   char * szLine = NULL;
   HB_SIZE nIndex, nLen = 0, nSize, nCol;

   if( nLine >= 1 )
   {
      if( hb_mlInit( &MLC, 1 ) )
      {
         while( --nLine )
         {
            if( ! hb_mlGetLine( &MLC ) )
               break;
         }
         if( nLine == 0 )
         {
            nIndex = MLC.nOffset;

            /* CA-Cl*pper also does not check if line exists and always
             * fill one line more, i.e.:
             *    for i := 0 to 4
             *       ? "[" + MemoLine( " ", 20, i ) + "]"
             *    next
             * [druzus]
             */
            hb_mlGetLine( &MLC );

            if( MLC.cdp )
               nSize = ( MLC.nOffset - nIndex ) + MLC.nLineLength;
            else
               nSize = MLC.nLineLength;
            szLine = ( char * ) hb_xgrab( nSize + 1 );
            nCol = 0;
            while( nIndex < MLC.nLen && nCol < MLC.nCol )
            {
               if( MLC.pszString[ nIndex ] == HB_CHAR_SOFT1 &&
                   MLC.pszString[ nIndex + 1 ] == HB_CHAR_SOFT2 )
                  nIndex += 2 ;
               else
               {
                  HB_WCHAR wc;

                  if( MLC.cdp )
                  {
                     if( ! HB_CDPCHAR_GET( MLC.cdp, MLC.pszString, MLC.nLen, &nIndex, &wc ) )
                        break;
                  }
                  else
                     wc = MLC.pszString[ nIndex++ ];

                  if( wc == HB_CHAR_HT )
                  {
                     HB_SIZE n = MLC.nTabSize - ( nLen % MLC.nTabSize );
                     do
                     {
                        szLine[ nLen++ ] = ' ';
                     }
                     while( ++nCol < MLC.nCol && --n );
                  }
                  else
                  {
                     if( MLC.cdp )
                     {
                        if( ! HB_CDPCHAR_PUT( MLC.cdp, szLine, nSize, &nLen, wc ) )
                           break;
                     }
                     else
                        szLine[ nLen++ ] = ( char ) wc;
                     ++nCol;
                  }
               }
            }
            if( nCol < MLC.nLineLength )
            {
               nCol = MLC.nLineLength - nCol;
               if( nCol > nSize - nLen )
                  nCol = nSize - nLen;
               memset( szLine + nLen, ' ', nCol );
               nLen += nCol;
            }
         }
         hb_mlExit( &MLC );
      }
   }
   if( szLine == NULL )
      hb_retc_null();
   else
      hb_retclen_buffer( szLine, nLen );
}
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Migrating to Harbour

Post by Antonio Linares »

Enrico,

More or less, how many text lines you have to read ?

I guess nPos saves the position where to start from

is it so ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:More or less, how many text lines you have to read ?
Unpredictable.
Antonio Linares wrote:I guess nPos saves the position where to start from

is it so ?
Yes, Memoline() updates it automatically. A simple and effective solution.

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

Re: Migrating to Harbour

Post by Antonio Linares »

Yes, Memoline() updates it automatically. A simple and effective solution
and very clever :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

Enrico Maria Giordano wrote:Another one: with Harbour I can't use CopyFile() to copy files with character like à. It returns .F.:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    MEMOWRIT( "testà", "" )

    ? COPYFILE( "testà", "testb" )

    RETURN NIL
EMG
I just found that

Code: Select all

MEMOWRIT( "testà", "" )
write

Code: Select all

testα
instead. But even if I create "testà" manually, CopyFile() return .F. and doesn't copy the file.

I have to set a specific codepage? Or?

EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Migrating to Harbour

Post by James Bott »

Enrico,

Are you saying it works with xHarbour but not with Harbour, or it doesn't work with either?
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

James,
James Bott wrote:Are you saying it works with xHarbour but not with Harbour, or it doesn't work with either?
xHarbour is fine. I'm trying unsuccessfull to migrate to Harbour... :-(

EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Migrating to Harbour

Post by James Bott »

You could try the code below. If it doesn't work either then it must be a Windows issue.

copyFile(cSource,cTarget,nFailIfExists)

Where nFailIfExists = 0 overwrite if cTarget exists
1 fail if cTarget exists

DLL32 FUNCTION CopyFile( Source_file AS LPSTR, Target_file AS
LPSTR,; Ret_err AS LONG ) AS BOOL FROM "CopyFileA" LIB
"Kernel32.dll"
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

James,

as I wrote, the problem is not only with CopyFile() but with MemoWrit() also. It could be a unicode problem with Harbour or some setting.

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

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

It works with the changes below:

Code: Select all

#include "Fivewin.ch"

REQUEST HB_CODEPAGE_ITWIN


FUNCTION MAIN()

    HB_SETCODEPAGE( "ITWIN" )

    MEMOWRIT( "testà", "" )

    ? COPYFILE( "testà", "testb" )

    RETURN NIL
Is that correct? I would prefer to not use something related to a specific language.

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

Re: Migrating to Harbour

Post by Antonio Linares »

Enrico,

great! :-)

So whats stopping you now to migrate to Harbour ? Just the MemoLine() code ?

You could try to use xHarbour MemoLine() source code from a #pragma BEGINDUMP ENDDUMP section
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

Antonio,

I have no reasons and don't want to migrate to Harbour. I'm only trying to test Harbour. If, during my tests, I will find any real improvements then I could change my mind.

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

Re: Migrating to Harbour

Post by Antonio Linares »

Enrico,

Yes, its a clever attitude :-)

As far as I know Harbour has built in support for unicode. Not sure if xHarbour provides that.

Anyhow thats all I can tell you. Still I am not very familiar with unicode and not sure how Harbour uses it.

In FWH 14.09 we included a work on progress unicode support for the Windows GUI, thanks to Ruediger help.
You can review FWH\samples\unicode.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Migrating to Harbour

Post by Enrico Maria Giordano »

Antonio,

I still wonder how did you migrate to Harbour. Have you ever had the need of creating or copying a filename with non-ascii characters???

EMG
Post Reply