Page 1 of 1

hb_hrbRun scripts ...

Posted: Wed Oct 07, 2009 6:43 pm
by Rimantas
Hi,

Here is a small sample for the problem ...

Code: Select all | Expand


#include "FiveWin.ch"
#include "InKey.ch"
#include "xBrowse.ch"

function sal_orders()
private oChild, oBrw
private cAls := oApp:GetNewAlias( "SALES" )

if !oApp:OpenNewAlias( "SALES", cAls )
   return( NIL )
endif

select( cAls )

DEFINE WINDOW oChild TITLE "Sales orders" MDICHILD OF oApp:oWnd

@ 0,0 XBROWSE oBrw OF oChild ALIAS Alias()

oBrw:CreateFromCode()
oBrw:cToolTip = "This is a sales orders"
oChild:oClient := oBrw
oChild:bValid  := { || ( .t., MsgInfo( "before" ), ( cAls )->( dbclosearea() ), MsgInfo( "after" ) ) }

ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()

return( NIL )  
 


I'm running prgs as scripts from hb_hrbrun() function . This sample is working , but ending this window , the main program hangs up and I must to close through task manager . The main reason of hangs up is oChild:bValid row - "after" msg doesn't appears . If comment this row , all is working OK . But I must to close this alias .. :-) . It seems that hb_hrbrun can't to do validation codeblock for window or close alias ... Tried without dbclosearea() - the same . So maybe it's problem of execution of codeblock ...

Thanks in advance for any ideas or comment !

Working enviroment : FW 9.05 , Harbour 2.0 a beta , BCC 5.5.1

Re: hb_hrbRun scripts ...

Posted: Thu Oct 08, 2009 9:07 pm
by Rimantas
Rimantas wrote:Hi,

Here is a small sample for the problem ...


It seems that with hb_hrbrun there aren't working mans ... :-(

Re: hb_hrbRun scripts ...

Posted: Thu Oct 08, 2009 9:54 pm
by Antonio Linares
Rimantas,

You can't use a private variable here:

private cAls := oApp:GetNewAlias( "SALES" )

because a MDICHILD window is non modal so the execution continues after activating the window and the private variable gets destroyed.

Use a local variable instead of a private, and it should work fine :-)

Re: hb_hrbRun scripts ...

Posted: Fri Oct 09, 2009 2:34 pm
by Rimantas
Antonio Linares wrote:Rimantas,

You can't use a private variable here:

private cAls := oApp:GetNewAlias( "SALES" )

because a MDICHILD window is non modal so the execution continues after activating the window and the private variable gets destroyed.

Use a local variable instead of a private, and it should work fine :-)


Thanks , Antonio , for your advice ! :) . I didn't try this , but believe , that this will be solved . I have another question - can I manage a script as object ? Now I programmed in this style - created one class , for sample "TSales" , in which exist DATA oChild , oBrw and methods for managment . In the main prg I'm creating oObj := TSales():New() and also put in array of all object { "sales", salesWindowHandle } . Then I know which object are opened , can manage them - this works perfect for me . Can I do something like that as desribed with scripts ?

Many thanks in advance ! With best regards !