Page 1 of 1

xBrowse ERROR

Posted: Thu Mar 13, 2014 1:39 pm
by vensanto
Hi
I have any time this error on my application
How to resolve it ???


Error DBCMD/2001 Workarea non in use: __DBSKIPPER

Stack-List
==========
Called from: => __DBSKIPPER(0)
Called from: fiveh\xbrowse.prg => (b)TXBROWSE_SETRDD(3936)
Called from: fiveh\xbrowse.prg => (b)TXBROWSE(436)
Called from: fiveh\xbrowse.prg => TXBROWSE:SKIP(0)
Called from: fiveh\xbrowse.prg => TXBROWSE:CALCROWSELPOS(1298)
Called from: fiveh\xbrowse.prg => TXBROWSE:REFRESH(1274)
Called from: XBRWDBF.PRG => (b)XBRW_DB(169)

Thanks to all

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 2:12 pm
by James Bott
Are you setting the xbrowse alias of the database?

James

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 2:23 pm
by vensanto
Yes

sometimes goes to error when I close the window
not always

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 2:25 pm
by ukoenig
Like James suggested :

DBSELECTAREA("CUST")

@ 35, 15 XBROWSE oBrw OF oXbrDlg1 ;
SIZE 400, 176 PIXEL ;
ALIAS "CUST" CELL LINES
...
...

Best regards
Uwe :?:

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 2:50 pm
by James Bott
Can we see your code for the browse?

James

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 4:16 pm
by vensanto
the problem is when i close the window
anytime go to error
regards


********************************************************************************************************************* // xBROWSE
Function XBRW_DB(nDBF,aDB,nFUN,nDES,nSRC,nSTA,nFIL,nBUT,oUSR,nSCH,nICO,bSALDO,nTAG,bCOLOR,bPOP,oFONT,bGO,nUFLT,bUKEY)
Local oWIN,oICO,oXDBF,oBAR,oPOPEXP
Local oBRW,nUSR:=0
Local oINS,oMOD,oCAN,oVIS,oANT,oSTA,oSRC,oFLT,oEXP
Local nUNO:=StrTran(IIF(AT("/",nDES)>0,Left(nDES,Len(nDES)-2),nDES) ,CHR(34),"")
Local nDUE:=StrTran(IIF(AT("/",nDES)>0,Left(nUNO,Len(nUNO)-1)+Right(nDES,1),nDES),CHR(34),"")
Local nTIT:=nDUE
Local nFILE:=Upper(StrTran(Alltrim(nTIT)," ","_"))
Local nARG:={}
Local nBT1:=IIF(nBUT<>NIL,IIF(AT("1",nBUT)>0,.T.,.F.),.T.) // Ins
Local nBT2:=IIF(nBUT<>NIL,IIF(AT("2",nBUT)>0,.T.,.F.),.T.) // Mod
Local nBT3:=IIF(nBUT<>NIL,IIF(AT("3",nBUT)>0,.T.,.F.),.T.) // Can
Local nBT4:=IIF(nBUT<>NIL,IIF(AT("4",nBUT)>0,.T.,.F.),.T.) // Vis
Local nBT5:=IIF(nBUT<>NIL,IIF(AT("5",nBUT)>0,.T.,.F.),.T.) // Ante
Local nBT6:=IIF(nBUT<>NIL,IIF(AT("6",nBUT)>0,.T.,.F.),.T.) // Stampa
Local nBT7:=IIF(nBUT<>NIL,IIF(AT("7",nBUT)>0,.T.,.F.),.T.) // Ricerca
Local nBT8:=IIF(nBUT<>NIL,IIF(AT("8",nBUT)>0,.T.,.F.),.T.) // Filtro
Local nBT9:=IIF(nBUT<>NIL,IIF(AT("9",nBUT)>0,.T.,.F.),.T.) // Export
Local oBUT1,oBUT2,oBUT3,oBUT4,oBUT5,oBUT6,oBUT7,oBUT8,oBUT9
Local oSALDO,nSALDO:="",nAREA
Local nUSRFLT:=IIF(nUFLT<>NIL,.T.,.F.)

oXDBF:=APRI_DB(nDBF)
(oXDBF)->(DBSetIndex(nDBF))
IF Len(aDB) > 0
IF !Empty( aDB[1][5] )
(oXDBF)->(DBSetOrder( aDB[1][5] ))
Endif
Endif

IF nFIL<>NIL
IF !Empty(AllTrim(nFIL))
(oXDBF)->( CMFILTER( nFIL ) )
Endif
Endif
(oXDBF)->(DBGoTop())
IF bGO<>NIL
(oXDBF)->(DBGoBottom())
Endif
nAREA:=ALIAS()

IF !Empty(nICO)
DEFINE ICON oICO RESOURCE (nICO+"_ICO")
Else
DEFINE ICON oICO RESOURCE (nFUN+"_ICO")
Endif
DEFINE WINDOW oWIN MDICHILD TITLE nTIT ICON oICO FROM 0,0 TO 0,0 PIXEL

oBRW:=XBRW_CREA(oWIN,aDB,oXDBF,,oFONT,,,,,,nTAG,,bCOLOR)

nARG:={oWIN,oXDBF,oBRW,oICO,nFUN,nUNO,nDUE,nSRC,aDB,nSCH,nICO,nDBF,bSALDO,oSALDO,nTAG,bCOLOR,nUSRFLT,bUKEY}

DEFINE BUTTONBAR oBAR OF oWIN SIZE 70,60 TOP
oBAR:l2007:=.T.


...


oBRW:bKeyDown :={|Key| XBRW_KEY(Key,nARG,oINS,oMOD,oCAN,oVIS,oANT,oSTA,oSRC,oFLT,oEXP,bUKEY)}
oBRW:bRClicked :={|R,C| XBRW_POP(R,C,nARG,oINS,oMOD,oCAN,oVIS,oANT,oSTA,oSRC,oFLT,oEXP,bPOP)}

oWIN:oClient:=oBRW
oWIN:SetControl(oBRW)

ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd) ;
VALID ( oBrw:bKeyCount:={||0} , oBrw:bKeyNo := {||0} , CLOSE_DB(oXDBF) , .T. )
Return .T.


************************ // Close DataBase
Function CLOSE_DB(oDBF)
IF oDBF<>NIL
(oDBF)->(DBCloseArea())
Return .T.
Endif
Return .F.

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 6:01 pm
by James Bott

Code: Select all

ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd) ;
VALID ( oBrw:bKeyCount:={||0} , oBrw:bKeyNo := {||0} , CLOSE_DB(oXDBF) , .T. )
I am not sure why you are using a VALID, but what is happening is that you are closing the database before the browse, thus the browse errors out.

Try:

Code: Select all

ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd) 

oXDBF:close()
 
I don't see why you need to reset oBrw:nKeyCount and oBrw:nKeyNo using a VALID since the entire window is being closed.

James

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 6:15 pm
by James Bott
Also, I don't understand this syntax:

(oDBF)->(DBCloseArea())

oDBF would have to be an alias except the prefix indicates that it is a database object. This is the generic syntax:

(cAlias)->(DBCloseArea())

However if oDBF is a database object (as the prefix indicates), then you close it this way:

(oDBF:cAlias)->(DBCloseArea())

But the database class already does this in it's Close method so you can just do this:

oDBF:close()

Actually, to be consistent with standard naming (polymorphism) it technically should be:

oDBF:end()

But our TDatabase class doesn't have an End() method so we have to use the Close() method. The advantage of polymorphism is that you can end any object using the same syntax.

James

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 8:15 pm
by vensanto
I don't use the class TDatabase

oDBF is the alias of database

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 10:04 pm
by James Bott
oDBF is the alias of database
OK, still you should change it to:

Code: Select all

ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd)

CLOSE_DB(oXDBF)
 
And your error will stop.

James

Re: xBrowse ERROR

Posted: Thu Mar 13, 2014 10:27 pm
by James Bott
oDBF is the alias of database
Oh, and Hungarian notation says that the alias variable should be cAlias not oDBF. The "o" prefix is to signify an object. Then people like me would be able to read your code more easily.

And if you were using a database object, the name would be very clear as:

oDBF:cAlias

And it would be even more clear with something like:

oCustomer:cAlias

However, if you are using database objects you very rarely have to use aliases. And there are lots of other reasons for using database objects. You should consider them. For more information see my website here: http://gointellitech.com/program.htm

Regards,
James

Re: xBrowse ERROR

Posted: Fri Mar 14, 2014 1:14 am
by vensanto
I go to try it

Thank you very much James

Re: xBrowse ERROR

Posted: Fri Mar 14, 2014 1:57 am
by cmsoft
Try pulling the focus to oBrw

Code: Select all

ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd) ;
VALID ( oBar:aControls[1]:SetFocus() , CLOSE_DB(oXDBF) , .T. )
Excuse my English

Re: xBrowse ERROR

Posted: Fri Mar 14, 2014 2:42 pm
by James Bott
Cmsoft,
Try pulling the focus to oBrw
The problem would still exist. The browse must be closed before the database is closed. Closing the database after the window is closed means that the browse is closed also. Closing the database in the VALID clause of the window means the database is closed before the browse, thus the browse errors out.

James

Re: xBrowse ERROR

Posted: Fri Mar 14, 2014 11:44 pm
by nageswaragunupudi
We should close the DBF "after" the window is closed. Once the window is closed, the browse object also is destroyed.

So, we should not close the DBF in the valid clause, because the window and browse objects are still active.

When we are using MDICHILD windows, the best place to close DBF is inside the oWin:bPostEnd codeblock. This codeblock is evaluated after the window is closed (and all controls are destroyed)


Please close the DBF in the oWin:bPostEnd codeblock.

Code: Select all

oWin:bPostEnd := { || ( cAlias )->( DBCLOSEAREA() ) }
This is the safe and recommended way.

In the case of your example above, please replace the code:

Code: Select all

oWIN:oClient:=oBRW
oWIN:SetControl(oBRW)

ACTIVATE WINDOW oWIN ON INIT WndAdjClient(oWIN:hWnd) ;
VALID ( oBrw:bKeyCount:={||0} , oBrw:bKeyNo := {||0} , CLOSE_DB(oXDBF) , .T. )
 
with

Code: Select all

oWIN:SetControl(oBRW)
oWin:bPostEnd := { || CLOSE_DB( oXDBF ) }

ACTIVATE WINDOW oWIN
 
Notes:
1) oWin:SetControl( oBrw ) includes a call to "oWin:oClient := oBrw".
2) ON INIT WndAdjClient(oWIN:hWnd) is not necessary.

I may also suggest that the caption is inappropriate. This is not Xbrowse error.