Page 1 of 1

Switching from xHarbour to Harbour

PostPosted: Fri Sep 28, 2012 10:14 pm
by Jeff Barnes
I am looking to switch from xHarbour to Harbour and was wondering if there is a list of things I need to watch out for ?

Re: Switching from xHarbour to Harbour

PostPosted: Sat Sep 29, 2012 3:34 am
by nageswaragunupudi
Very simple.

Please add #include "hbcompat.ch" at the top of every module and link xhb.lib in the link script. Mostly this is what all that needs to be done.

However very few incompatibles remain.
Negative array indexes which work in XHarbour do not work in Harbour.
Eg: You need to change aData[ -1 ] as ATail( aData ),
aData[ -n ] as aData[ Len( aData ) - n + 1 ]

In case you have used array type of indexes to Character variables you need to convert them as SubStr.

Except these two, everythingelse should work well with Harbour.

Re: Switching from xHarbour to Harbour

PostPosted: Sat Sep 29, 2012 8:04 am
by Franklin Demont
Jeff Barnes wrote:I am looking to switch from xHarbour to Harbour and was wondering if there is a list of things I need to watch out for ?

Jeff ,

I have finished the conversion , a big aplication (+/- 30 prg-files , i worked on it during a month) . The goal is to have a aplication that can be build with xharbour and harbour.

I will try to give the problems which i had , hopely this day

Some problems can you find in this forum the last days

Frank

Re: Switching from xHarbour to Harbour

PostPosted: Sat Sep 29, 2012 1:32 pm
by Franklin Demont
Franklin Demont wrote:
Jeff Barnes wrote:I am looking to switch from xHarbour to Harbour and was wondering if there is a list of things I need to watch out for ?

Jeff ,

I have finished the conversion , a big aplication (+/- 30 prg-files , i worked on it during a month) . The goal is to have a aplication that can be build with xharbour and harbour.

I will try to give the problems which i had , hopely this day

Some problems can you find in this forum the last days

Frank


1) As xMate user i searched for a envirronement-file in the forum :
viewtopic.php?f=3&t=22823&p=127863&hilit=xmate+harbour#p127863
HB_COMMAND should not define __HARBOUR__ , it is defined in the compiler

2) In each program module :

# ifdef __HARBOUR__
# ifndef __XHARBOUR__
# include "xhb.ch"
# include "xhbcls.ch"
# INCLUDE "xset.ch" // From xharbour , in include
# define ATAILh(Arr) Arr[LEN(Arr)]
# endif
# endif

xSet.ch : Missing defines from set.ch (HARBOUR) , i.e. _SET_ERRORLOG_
ATAILh(Arr) : Xharbour accepts ATAIL(Arr) := ..... , HARBOUR doesn't
You have to search manually this cases and change in ATAILh(arr) (case sensitive)
(or compile and search the lines with the error)
IN mine case i had also ATAIL(Arr[n]) , i used ATAILH(Arr,n) Arr[n,LEN(Arr[n])]

3) PREDEFINES

IF x IN y must be IF (x IN y)

I had also problems with (try to remember):
WITH OBJECT obj
SomeArr[:Someproperty] ==> SomeArr[Obj:SomeProperty]
END

4) Xharbour has no problems with (faulty) expressions as :
obrw:bPastEof()
oDlg:end
It can be very dificult to find such error , see viewtopic.php?f=3&t=24820#p134633

5) See also viewtopic.php?f=3&t=24902#p135294
INIT module can not have xharbout extensions

6) The bigest problem is GLOBAL and GLOBAL EXTERNAL variables from xharbour. See the sample.
To test create 3 prg-files as indicated , in xharbour globalvar.prg is not linked in
Code: Select all  Expand view

// Mainmodule , first prg-file
# include "FiveWin.ch"
# ifdef __HARBOUR__
# ifndef __XHARBOUR__
# include "xhb.ch"
# define _oWnd    g():oWnd
# else    // __XHARBOUR__
GLOBAL _oWnd
# endif   // __XHARBOUR__
# endif
PROC MAIN
**********
DEFINE WINDOW _oWnd FROM 0, 0 TO 24, 80 MDI;
MENU BuildMenu()
ACTIVATE WINDOW _oWnd MAXIMIZED
RETURN
function BuildMenu()
************************
local oMenu
LOCAL oMenuItem
MENU oMenu
 MENUITEM "Dialog from Main window";
       ACTION TestDlg()
ENDMENU
RETURN oMenu
***********************************************************************
//DIALOG.PRG , second prg-file
# include "FiveWin.ch"
# ifdef __HARBOUR__
# ifndef __XHARBOUR__
# include "xhb.ch"
# define _oWnd    g():oWnd
# else    // __XHARBOUR__
GLOBAL EXTERNAL _oWnd
# endif   // __XHARBOUR__
# endif
PROC TestDlg()
**************
LOCAL oDlg
DEFINE DIALOG oDlg OF _oWnd FROM 0, 0 TO 20, 60
ACTIVATE DIALOG oDlg
RETURN
***********************************************************************
//GLOBALVAR.PRG  third prg-file , only linked in with HARBOUR
# include "FiveWin.ch"
# ifdef __HARBOUR__
# include "xhb.ch"
STATIC g
# endif
class GlobalVar
***************
VAR oWnd
END CLASS
***************
Function g()
***********
RETURN g
 


7) Associative arrays
See viewtopic.php?f=3&t=24919#p135460