Page 1 of 1

harbour behaviour on DIALOG INIT

Posted: Wed Mar 05, 2025 3:40 pm
by JoséQuintas
SYSTEM ERROR
Error BASE/1004 Message not found: TDIALOG:BCODEBLOCK
Called from __ERRRT_SBASE(0)
Called from TDIALOG:ERROR(0)
Called from (b)HBOBJECT(0)
Called from TDIALOG:MSGNOTFOUND(0)
Called from TDIALOG:BCODEBLOCK(0)
Called from (b)DLGTEXTMSGCLASS_EXECUTE(118)
Called from TDIALOG:INITIATE(0)
Called from TDIALOG:HANDLEEVENT(0)
Called from DIALOGBOXINDIRECT(0)
Called from TDIALOG:ACTIVATE(0)
Called from DLGTEXTMSGCLASS:EXECUTE(118)
Called from ZE_FWTEXTMSG(9)
Called from DO(0)
Called from DOPRG(152)
First code, ok no error:

Code: Select all | Expand

PROCEDURE ze_fwTextMsg

   LOCAL oDlgMsg

   oDlgMsg := DlgTextMsgClass():New()
   oDlgMsg:bCodeBlock := { || ThisTest( oDlgMsg ) }
   oDlgMsg:Execute()
Class ok

Code: Select all | Expand

CREATE CLASS DlgTextMsgClass

   VAR xDlg
   ...
   VAR bCodeBlock
   METHOD Execute()
Method Execute() have the "problem"

Code: Select all | Expand

METHOD Execute() CLASS DlgTextMsgClass
...
   IF ::bCodeBlock == Nil
      ACTIVATE DIALOG ::xDlg CENTERED
   ELSE
      ACTIVATE DIALOG ::xDlg CENTERED ;
         ON INIT ( (Self), Eval( ::bCodeBlock ) )
   ENDIF
...
What is the problem ?
ON INIT uses Self as parameter - Self is TDIALOG
Eval( ::bCodeBlock ) uses Self, but uses TDIALOG Class and not DlgTextMsgClass
TDIALOG does not have bCodeBlock.

Re: harbour behaviour on DIALOG INIT

Posted: Wed Mar 05, 2025 4:14 pm
by JoséQuintas
May be the #translate or anything else.
I will made a test using oDlg:bInit.

Re: harbour behaviour on DIALOG INIT

Posted: Wed Mar 05, 2025 5:58 pm
by Antonio Linares
Dear Jose,

Please try it this way:

Code: Select all | Expand

METHOD Execute() CLASS DlgTextMsgClass
   local oThis := Self
...
   IF ::bCodeBlock == Nil
      ACTIVATE DIALOG ::xDlg CENTERED
   ELSE
      ACTIVATE DIALOG ::xDlg CENTERED ;
         ON INIT ( (Self), Eval( oThis:bCodeBlock ) )
   ENDIF
...

Re: harbour behaviour on DIALOG INIT

Posted: Thu Mar 06, 2025 2:56 pm
by JoséQuintas
Found this way

Code: Select all | Expand

IF ::bCodeBlock != Nil
   ::xDlg:bInit := ::bCodeBlock
ENDIF   
ACTIVATE DIALOG ::xDLG CENTERED
Thanks.

Note:
Behaviour is created by #xcommand using self as parameter, to be used on codeblock.

Code: Select all | Expand

[{|Self|<uInit>}]
If change this, it may becames incompatible with existing routines.
Souce code looks clearer using bInit.