Excel OLE RTE when compiled with Harbour

hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Excel OLE RTE when compiled with Harbour

Post by hua »

Hi guys,
I'm trying to migrate a module that I have to FWH+Harbour instead of xHb
However this line of code generates RTE under Harbour but ran fine all this while under xHb

Code: Select all | Expand

 ::oSheet := ::oExcel:ActiveSheet
 ::oSheet:set("Name", "A & T ELEC")
 


The error was
FiveWin version: FWH 19.05
C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
Windows version: 10.0, Build 18363

Time from start: 0 hours 0 mins 18 secs
Error occurred at: 23/08/2022, 14:28:59
Error description: (DOS Error -2147352572) WINOLE/1007 Argument error: SET
Args:
[ 1] = C Name
[ 2] = C A & T ELEC

Stack Calls
===========
Called from: => TOLEAUTO:SET( 0 )
Called from: .\statprnx.PRG => STATPRNXLS:HEADER( 136 )


Anyone has any idea of how to solve this?
TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by Antonio Linares »

Dear Hua,

Please try it again removing the "&" to see if that makes a difference:

::oSheet:set("Name", "A T ELEC")
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Excel OLE RTE when compiled with Harbour

Post by hua »

Thanks for the prompt reply Antonio.

Removing '&' didn't help. The same error occured
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Excel OLE RTE when compiled with Harbour

Post by cnavarro »

Try with

Code: Select all | Expand


::oSheet := ::oExcel:ActiveSheet
 ::oSheet:name := "A & T ELEC"
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Excel OLE RTE when compiled with Harbour

Post by hua »

Thanks Cristobal! That was it :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Excel OLE RTE when compiled with Harbour

Post by hua »

Another error I found after compiling with Harbour. Instead of a logical value, lRetVal ends up with an array {0, 5813120}

Code: Select all | Expand


      lRetVal := StatPrnXls():activate(cTitle, cFrom, cTo, dCOD, lPrnZero)
      return lRetVal


I don't even know where to begin to find out what went wrong. The last line in StatPrnXls():activate() simply returns .t. and yet lRetVal ends up with an array

Any tips? Suggestions?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
Antonio Linares
Site Admin
Posts: 42597
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 40 times
Been thanked: 86 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by Antonio Linares »

You could try this:

instead of
return lRetVal

use
return lRetVal[ 2 ] != 0
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Excel OLE RTE when compiled with Harbour

Post by hua »

Whether StatPrnXls():activate() returns .t. or .f. lRetVal always ends up with {0, 5813120}

I can't wrap my mind on what's happening. Called class returns a logical value yet lRetVal ends up with an array
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by nageswaragunupudi »

May I know what is this "StatPrnXls()" ?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by nageswaragunupudi »

May I know what is this "StatPrnXls()" ?
Regards

G. N. Rao.
Hyderabad, India
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Excel OLE RTE when compiled with Harbour

Post by hua »

Hi Rao,
StatPrnXls() is a class in my program that generates a report directly in Excel using OLE.
The last line in StatPrnCls():activate() is return .t. hence my bewilderment when lRetVal contains an array
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by nageswaragunupudi »

Nice.
Do you mind sharing your class with me?
Regards

G. N. Rao.
Hyderabad, India
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: Excel OLE RTE when compiled with Harbour

Post by hua »

It's just a crude report written in class form as I try to avoid using public,private variable as much as possible :)
Irregardless, I've emailed it to you.
Thank you
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by nageswaragunupudi »

Thank you
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: Excel OLE RTE when compiled with Harbour

Post by nageswaragunupudi »

I remember having experienced the same problem, when I was writing the METHOD ToExcel() of XBrowse.
Please see my notes towards the end of ToExcel() method in XBrowse.

Code: Select all | Expand


#ifndef __XHARBOUR__
   else
      //
      SysRefresh()
      //
      // This requires explanation.
      // With xHarbour there is no problem. Problem is with Harbour only
      // return value of this function is oSheet which is an Object. xHarbour returns as object
      // If SysRefresh() is called here, Harbour returns oSheet as an object
      // if not it returns an Array of two numeric elements.
      // I am unable to understand this phenomenon.
      // Till we understand what is happening, keep SysRefresh() here for
      // Harbour build.
      // 2015-06-02
#endif
   endif

return oSheet
 


So, in your case also I guess xHarbour returns .T. but Harbour returns an array of two numeric elements.

Please insert

Code: Select all | Expand

SysRefresh()

just beore

Code: Select all | Expand

return .t.


I expect this will solve your problem.
Please test and let us know the result.
Regards

G. N. Rao.
Hyderabad, India
Post Reply