Migrating to Harbour

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sat Dec 13, 2014 10:15 am

Antonio,

yes: too many differences for me:

Code: Select all  Expand view  RUN
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
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby Antonio Linares » Sat Dec 13, 2014 10:18 am

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
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sat Dec 13, 2014 10:24 am

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
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby Antonio Linares » Sat Dec 13, 2014 10:27 am

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


and very clever :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sat Dec 13, 2014 3:45 pm

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  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    MEMOWRIT( "testà", "" )

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

    RETURN NIL


EMG


I just found that

Code: Select all  Expand view  RUN
MEMOWRIT( "testà", "" )


write

Code: Select all  Expand view  RUN
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
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby James Bott » Sat Dec 13, 2014 6:43 pm

Enrico,

Are you saying it works with xHarbour but not with Harbour, or it doesn't work with either?
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sat Dec 13, 2014 6:47 pm

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
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby James Bott » Sat Dec 13, 2014 7:31 pm

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
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sat Dec 13, 2014 7:37 pm

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: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sun Dec 14, 2014 11:11 am

It works with the changes below:

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby Antonio Linares » Sun Dec 14, 2014 11:24 am

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
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sun Dec 14, 2014 11:40 am

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
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sun Dec 14, 2014 11:41 am

What is the best and language neutral way to activate unicode?

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

Re: Migrating to Harbour

Postby Antonio Linares » Sun Dec 14, 2014 11:45 am

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
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migrating to Harbour

Postby Enrico Maria Giordano » Sun Dec 14, 2014 1:24 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests