Alaska Software Inc. - SubClassing XbpCrt()
Username: Password:
AuthorTopic: SubClassing XbpCrt()
Carlos Antonio BelingSubClassing XbpCrt()
on Thu, 19 Aug 2021 16:23:32 -0300
Hi.
Good day.
I tried to subclass XbpCrt() using the attached file Test.prg as example 
and it is giving the error Access to method not allowed within class-object.
Also the error occurs when you compile the program and link it using xpp 
test /link
Please, if possiblle, how to fix this error?

Fraternally
Beling


Test.prg
Project.xpj
Jim LeeRe: SubClassing XbpCrt()
on Fri, 20 Aug 2021 06:26:44 +0200
hi,

never have try to subclass CRT ...

i use this Sample

PROCEDURE main()
LOCAL oCrt, oHadFocus
oCrt := DerivedCrt():new(NIL, NIL, {50,50}, 25, 80, 'Testing', .t.)
oCrt:create()
oHadFocus := SetAppFocus(oCrt)
oCrt:say()
SetAppFocus(oHadFocus)
RETURN

 PROCEDURE AppSys()
 RETURN
PROCEDURE DbeSys()
RETURN

CLASS DerivedCrt FROM XbpCrt
EXPORTED:
   METHOD init()
   METHOD create()
   METHOD say()
ENDCLASS

METHOD DerivedCrt:init(oParent, oOwner, aPos, nRowCount, nColCount, cTitle, 
lVisible)
   ::XbpCrt:init(oParent, oOwner, aPos, nRowCount, nColCount, cTitle, 
lVisible)
RETURN self

METHOD DerivedCrt:create(oParent, oOwner, aPos, nRowCount, nColCount, 
cTitle, lVisible)
   ::XbpCrt:create(oParent, oOwner, aPos, nRowCount, nColCount, cTitle, 
lVisible)
RETURN self

METHOD DerivedCrt:say()
*   SetColor('n/w*')
   cls
   SetPos(12, 30)
   QQOut('Type something')
   InKey(0)
RETURN Self


if i set GUI=no i got
------------------------------------------------------------------------------
FEHLERPROTOKOLL von "D:\ALASKA\CRTCLASS\Test.exe" Datum: 20.08.2021 06:18:02

Xbase++ Version     : Xbase++ (R) Version 1.90.355
Betriebssystem      : Windows Vista 06.02 Build 09200
------------------------------------------------------------------------------
oError:args         :
          -> VALTYPE: O CLASS: DerivedCrt
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: U VALUE: NIL
          -> VALTYPE: U VALUE: NIL
oError:canDefault   : N
oError:canRetry     : N
oError:canSubstitute: J
oError:cargo        : NIL
oError:description  : Falscher Datentyp fr Member-Variable
oError:filename     :
oError:genCode      :         29
oError:operation    : Status
oError:osCode       :          0
oError:severity     :          2
oError:subCode      :       2248
oError:subSystem    : BASE
oError:thread       :          1
oError:tries        :          0
------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------
Aufgerufen von XBPCRT:CREATE(666)
Aufgerufen von DERIVEDCRT:CREATE(29)
Aufgerufen von MAIN(6)


if i set GUI=yes i got
------------------------------------------------------------------------------
FEHLERPROTOKOLL von "D:\ALASKA\CRTCLASS\Test.exe" Datum: 20.08.2021 06:11:44

Xbase++ Version     : Xbase++ (R) Version 1.90.355
Betriebssystem      : Windows Vista 06.02 Build 09200
------------------------------------------------------------------------------
oError:args         :
          -> VALTYPE: C VALUE: Type something
oError:canDefault   : N
oError:canRetry     : J
oError:canSubstitute: N
oError:cargo        : NIL
oError:description  : Zugriff auf Methode nicht erlaubt
oError:filename     :
oError:genCode      :         25
oError:operation    : qqOut
oError:osCode       :          0
oError:severity     :          2
oError:subCode      :       4402
oError:subSystem    : BASE
oError:thread       :          1
oError:tries        :          4
------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------
Aufgerufen von DERIVEDCRT:SAY(36)
Aufgerufen von MAIN(8)

so i guess it is not possible to subclass CRT



---
Diese E-Mail wurde von AVG auf Viren gepruft.
http://www.avg.com
Carlos Antonio BelingRe: SubClassing XbpCrt()
on Fri, 20 Aug 2021 12:41:43 -0300
Hi Jim.
Good day.
Many thanks.
I read all the docs and they do not mention this condition.
If I could subclass XbpCrt() or to insert a method in oCrt 
(XbpCrt():new()...) I could to something like this:

METHOD NewCrt:lockPS()
RETURN ::presSpace()
METHOD NewCrt:unlockPS()
RETURN NIL

This way the Gra...() functions could did not need to check for using f 
:lockPS() or :presSpace() for painting in any oXbp. Then always they can 
using :lockPS().

Fraternally
Beling


On 20/08/2021 01:26, Jim Lee wrote:
> hi,
> 
> never have try to subclass CRT ...
> 
> i use this Sample
> 
> PROCEDURE main()
> LOCAL oCrt, oHadFocus
> oCrt := DerivedCrt():new(NIL, NIL, {50,50}, 25, 80, 'Testing', .t.)
> oCrt:create()
> oHadFocus := SetAppFocus(oCrt)
> oCrt:say()
> SetAppFocus(oHadFocus)
> RETURN
> 
>  PROCEDURE AppSys()
>  RETURN
> PROCEDURE DbeSys()
> RETURN
> 
> CLASS DerivedCrt FROM XbpCrt
> EXPORTED:
>     METHOD init()
>     METHOD create()
>     METHOD say()
> ENDCLASS
> 
> METHOD DerivedCrt:init(oParent, oOwner, aPos, nRowCount, nColCount, cTitle,
> lVisible)
>     ::XbpCrt:init(oParent, oOwner, aPos, nRowCount, nColCount, cTitle,
> lVisible)
> RETURN self
> 
> METHOD DerivedCrt:create(oParent, oOwner, aPos, nRowCount, nColCount,
> cTitle, lVisible)
>     ::XbpCrt:create(oParent, oOwner, aPos, nRowCount, nColCount, cTitle,
> lVisible)
> RETURN self
> 
> METHOD DerivedCrt:say()
> *   SetColor('n/w*')
> *   cls
> *   SetPos(12, 30)
>     QQOut('Type something')
>     InKey(0)
> RETURN Self
> 
> 
> if i set GUI=no i got
> ------------------------------------------------------------------------------
> FEHLERPROTOKOLL von "D:\ALASKA\CRTCLASS\Test.exe" Datum: 20.08.2021 06:18:02
> 
> Xbase++ Version     : Xbase++ (R) Version 1.90.355
> Betriebssystem      : Windows Vista 06.02 Build 09200
> ------------------------------------------------------------------------------
> oError:args         :
>            -> VALTYPE: O CLASS: DerivedCrt
>            -> VALTYPE: U VALUE: NIL
>            -> VALTYPE: U VALUE: NIL
>            -> VALTYPE: U VALUE: NIL
>            -> VALTYPE: U VALUE: NIL
>            -> VALTYPE: U VALUE: NIL
>            -> VALTYPE: U VALUE: NIL
>            -> VALTYPE: U VALUE: NIL
> oError:canDefault   : N
> oError:canRetry     : N
> oError:canSubstitute: J
> oError:cargo        : NIL
> oError:description  : Falscher Datentyp für Member-Variable
> oError:filename     :
> oError:genCode      :         29
> oError:operation    : Status
> oError:osCode       :          0
> oError:severity     :          2
> oError:subCode      :       2248
> oError:subSystem    : BASE
> oError:thread       :          1
> oError:tries        :          0
> ------------------------------------------------------------------------------
> CALLSTACK:
> ------------------------------------------------------------------------------
> Aufgerufen von XBPCRT:CREATE(666)
> Aufgerufen von DERIVEDCRT:CREATE(29)
> Aufgerufen von MAIN(6)
> 
> 
> if i set GUI=yes i got
> ------------------------------------------------------------------------------
> FEHLERPROTOKOLL von "D:\ALASKA\CRTCLASS\Test.exe" Datum: 20.08.2021 06:11:44
> 
> Xbase++ Version     : Xbase++ (R) Version 1.90.355
> Betriebssystem      : Windows Vista 06.02 Build 09200
> ------------------------------------------------------------------------------
> oError:args         :
>            -> VALTYPE: C VALUE: Type something
> oError:canDefault   : N
> oError:canRetry     : J
> oError:canSubstitute: N
> oError:cargo        : NIL
> oError:description  : Zugriff auf Methode nicht erlaubt
> oError:filename     :
> oError:genCode      :         25
> oError:operation    : qqOut
> oError:osCode       :          0
> oError:severity     :          2
> oError:subCode      :       4402
> oError:subSystem    : BASE
> oError:thread       :          1
> oError:tries        :          4
> ------------------------------------------------------------------------------
> CALLSTACK:
> ------------------------------------------------------------------------------
> Aufgerufen von DERIVEDCRT:SAY(36)
> Aufgerufen von MAIN(8)
> 
> so i guess it is not possible to subclass CRT
> 
> 
> 
> ---
> Diese E-Mail wurde von AVG auf Viren gepruft.
> http://www.avg.com
>
Andreas Gehrs-Pahl
Re: SubClassing XbpCrt()
on Fri, 20 Aug 2021 16:38:27 -0400
Carlos,

>I tried to subclass XbpCrt() using the attached file Test.prg as example 
>and it is giving the error Access to method not allowed within class-object.

There are several errors and issues in your code that cause those problems. 
I have a attached a working version of your program.

First, you can't call the o:Init() method of an object, but you must call 
the o:New() method instead. Second, text based output -- such as QOut() -- 
always goes to the object identified as the Application window (or the 
RootCRT() object, if you are in console mode). So, before you can use 
SetColor() and similar functions, you must set the Application window to 
your object, using SetAppWindow() -- not SetAppFocus().

Additionally, it is much easier to simply use the "Super" pseudo-variable, 
which is similar to "Self", and which, when nothing else is specified, 
invokes the method with the same name of the Super Class from which your 
class is derived from, using the same variables as your current method.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC

XbpCRT_Test.prg
Andreas Gehrs-Pahl
Re: SubClassing XbpCrt()
on Fri, 20 Aug 2021 16:56:17 -0400
Carlos,

I forgot to change the "SetAppFocus(oHadFocus)" in line 26 to 
"SetAppWindow(oHadFocus)", but you'll get the idea.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Carlos Antonio BelingRe: SubClassing XbpCrt()
on Fri, 20 Aug 2021 19:25:07 -0300
Hi Andreas.
Good day.
Many thanks again.
Genial.
I never would imagine using "Super" like this.
How long we live much more we learn.

Fraternally
Beling

On 20/08/2021 17:38, Andreas Gehrs-Pahl wrote:
> Carlos,
> 
>> I tried to subclass XbpCrt() using the attached file Test.prg as example
>> and it is giving the error Access to method not allowed within class-object.
> 
> There are several errors and issues in your code that cause those problems.
> I have a attached a working version of your program.
> 
> First, you can't call the o:Init() method of an object, but you must call
> the o:New() method instead. Second, text based output -- such as QOut() --
> always goes to the object identified as the Application window (or the
> RootCRT() object, if you are in console mode). So, before you can use
> SetColor() and similar functions, you must set the Application window to
> your object, using SetAppWindow() -- not SetAppFocus().
> 
> Additionally, it is much easier to simply use the "Super" pseudo-variable,
> which is similar to "Self", and which, when nothing else is specified,
> invokes the method with the same name of the Super Class from which your
> class is derived from, using the same variables as your current method.
> 
> Hope that helps,
> 
> Andreas
>