FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE : Error in refresh
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 09:52 AM
Hello,

I am sorry to ask again some help for xbrowse , but i am converting in a big aplication all the browses to xbrowse.

Folowing the advice from nageswaragunupudi , i try to use xbrowsenew (pre processor)

I have a array from 3 elements , the last should have focus when the dialog is opened

StartNr := 3
@ 0,0 XBROWSE oBrw OF oDlg;
    ARRAY Arr AUTOSORT
ACTIVATE DIALOG oDlg ;
    ON Init (oBrw:nArrayAt := StartNr  )


Now i have a error in refresh (839)

// NkeyNo = ::nLen = 3
if nKeyNo >= ::nLen .and. ::nLen > 1
   ::nRowSel   := Min( nKeyNo, ::RowCount() )
endif


::RowCount() is executed , and gives a error while ::nRowHeight is not defined (only defined in adjust , is not yet executed)

Is there another way to give the last row focus at startup ?

It seems a error , or am i missing something ?

Frank

Error description: Error BASE/1084 Argument error: /
Args:
[ 1] = N 82
[ 2] = U

Stack Calls
===========
Called from: xbrowse.prg => (b)TXBROWSE:TXBROWSE(400)
Called from: => TXBROWSE:ROWCOUNT(0)
Called from: xbrowse.prg => TXBROWSE:REFRESH(858)
Called from: xcombox8.08\XXBROWSE.PRG => TXBRWCOLUMN:MYSORTARRAY(236)
Called from: xcombox8.08\XXBROWSE.PRG => (b)TXBROWSE:MYSETARRAY(159)
Called from: => AEVAL(0)
Called from: xcombox8.08\XXBROWSE.PRG => TXBROWSE:MYSETARRAY(159)
Called from: xbrowse.prg => XBRWSETDATASOURCE(7692)
Called from: xbrowse.prg => XBROWSENEW(7563)
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
Re: XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 10:44 AM
demont frank wrote:Hello,

I have a array from 3 elements , the last should have focus when the dialog is opened

StartNr := 3
@ 0,0 XBROWSE oBrw OF oDlg;
    ARRAY Arr AUTOSORT
ACTIVATE DIALOG oDlg ;
    ON Init (oBrw:nArrayAt := StartNr  )


Now i have a error in refresh (839)

// NkeyNo = ::nLen = 3
if nKeyNo >= ::nLen .and. ::nLen > 1
   ::nRowSel   := Min( nKeyNo, ::RowCount() )
endif


::RowCount() is executed , and gives a error while ::nRowHeight is not defined (only defined in adjust , is not yet executed)

Is there another way to give the last row focus at startup ?

It seems a error , or am i missing something ?

Frank




The value from nRecno (or oBrw:nArrayAt) is set on line 7354 :

uSave    := ::oBrw:aArrayData[ ::oBrw:nArrayAt ][ ::nArrayCol ]
.....
::oBrw:nArrayAt   := AScan( ::oBrw:aArrayData, { |a| a[ ::nArrayCol ] == uSave } )   <=Line 7354


It is a coincidence that this gives the last line. So the problems have nothing to do with the INIT clausule oBrw:nArrayAt := ....

Frank
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 11:55 AM

Frank,

Could you please provide a small and self contained PRG to test it here ? thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 12:02 PM
Frank,

This example is working fine here:
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, oBrw, arr := { "one", "two", "three" }, StartNr := 3
   
   DEFINE DIALOG oDlg

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY arr AUTOSORT

   oBrw:CreateFromCode()
         
   oDlg:oClient = oBrw   
      
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oBrw:nArrayAt := StartNr, oDlg:ReSize() )
      
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 03:41 PM
Antonio Linares wrote:Frank,

This example is working fine here:
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, oBrw, arr := { "zone", "two", "three" }, StartNr := 3
   
   DEFINE DIALOG oDlg

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY arr AUTOSORT

   oBrw:CreateFromCode()
         
   oDlg:oClient = oBrw   
      
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oBrw:nArrayAt := StartNr, oDlg:ReSize() )
      
return nil


Antonio,

I am afraid you missed something. I changed your example. At startup (before initialisizing) oBrw:nArrayAt = 1 . From xbrowsenew , XbrwSetDataSource is called oBrw:setarray. While autosort is .T. , this array is ordered , after memorising element 1 (zone) , then obrw:nArrayAt is set to the new index from zone (now the last one==::nLen) , so line 839-841 :
if nKeyNo >= ::nLen .and. ::nLen > 1
   ::nRowSel   := Min( nKeyNo, ::RowCount() )  <= is executed !!!!!
endif

METHOD RowCount()     INLINE Int( ( ::BrwHeight() - ::HeaderHeight() - ::FooterHeight() ) / ::nRowHeight )


::nRowheight receives his value in oBrw:Adjust , but this is not yet executed

I thought that this was explained in the previous threads

Frank


Application
===========
Error description: Error BASE/1084 Argument error: /

Args:
[ 1] = N 183
[ 2] = U

Stack Calls
===========
Called from: xbrowse.prg => (b)TXBROWSE:TXBROWSE(397)
Called from: => TXBROWSE:ROWCOUNT(0)
Called from: xbrowse.prg => TXBROWSE:REFRESH(840)
Called from: xbrowse.prg => TXBRWCOLUMN:SORTARRAYDATA(7292)
Called from: xbrowse.prg => TXBROWSE:SETARRAY(3222)
Called from: xbrowse.prg => TXBROWSE:INITIATE(655)

Executing
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 06:35 PM

Frank,

> I changed your example.

Please provide my modified example to test it here, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Thu Oct 09, 2008 06:40 PM
Frank,

This may help:
METHOD RowCount() INLINE If( ::nRowHeight() == nil, ::Adjust(),), Int( ( ::BrwHeight() - ::HeaderHeight() - ::FooterHeight() ) / ::nRowHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
XBROWSE : Error in refresh
Posted: Fri Oct 10, 2008 06:42 AM
Antonio Linares wrote:Frank,

> I changed your example.

Please provide my modified example to test it here, thanks


As you could see i have changed

local oDlg, oBrw, arr := { "one", "two", "three" } , StartNr := 3

IN

local oDlg, oBrw, arr := { "zone", "two", "three" } , StartNr := 3

Your solution seems to work , but it is good to know that startnr is the index in the sorted array , here zone. A better aproach would be :

ON INIT ( StartNr := ASCAN(oBrw:aArrayData,"three") , oBrw:nArrayAt := StartNr, oDlg:ReSize() )
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
ERROR NOT SOLVED
Posted: Sat Oct 11, 2008 04:52 AM
Antonio Linares wrote:Frank,

This may help:
METHOD RowCount() INLINE If( ::nRowHeight() == nil, ::Adjust(),), Int( ( ::BrwHeight() - ::HeaderHeight() - ::FooterHeight() ) / ::nRowHeight )


Antonio,

I am afraid that your solution doesn't work in the case Rowcount() is called before the initialisizing from the dialog.

In mine fist thread i reported the problem , in the error.log you can see that the error occur before the dialog is initialisized , comming from xbrosenew , XbrwSetDataSource

      if lAddCols .or. ! Empty( aCols )
         oBrw:SetArray( uDataSrc, lAutoSort, 1, aCols ) <= line 7613
      else
         oBrw:SetArray( uDataSrc, nil, nil, .f. )               <= line 7615
      endif


In your example setarray is called from 7615 , in mine from 7613

In Setarray , the 4-th parameter set lAddcol to .F. (calling from 7615) , otherwise on .T. , at least when len(acols) > 0

Sortarray and refresh will only executed when lAddCol = .T. . In this case
:Rowcount() , and with your solution adjust is executed before the initialisizing from the dialog . You can try :


function Main()

   local oDlg, oBrw, arr := { "zone", "two", "three" } , StartNr := 3

   DEFINE DIALOG oDlg

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY arr AUTOSORT ;
	COLUMNS 1;
	SIZES 100

   oBrw:CreateFromCode()

   oDlg:oClient = oBrw

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( StartNr := ASCAN(oBrw:aArrayData,"three") , oBrw:nArrayAt := StartNr, oDlg:ReSize() )

return nil
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Sat Oct 11, 2008 07:22 AM
Frank,

Try it this way:
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main() 

   local oDlg, oBrw, arr := { "zone", "two", "three" } , StartNr := 3 

   DEFINE DIALOG oDlg 

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY arr AUTOSORT  

   oBrw:CreateFromCode() 

   oDlg:oClient = oBrw 

   ACTIVATE DIALOG oDlg CENTERED ; 
      ON INIT ( StartNr := ASCAN(oBrw:aArrayData,"three") , oBrw:nArrayAt := StartNr, oDlg:ReSize() )
      
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
XBROWSE : Error in refresh
Posted: Sat Oct 11, 2008 08:43 AM
Antonio Linares wrote:Frank,

Try it this way:
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main() 

   local oDlg, oBrw, arr := { "zone", "two", "three" } , StartNr := 3 

   DEFINE DIALOG oDlg 

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY arr AUTOSORT  

   oBrw:CreateFromCode() 

   oDlg:oClient = oBrw 

   ACTIVATE DIALOG oDlg CENTERED ; 
      ON INIT ( StartNr := ASCAN(oBrw:aArrayData,"three") , oBrw:nArrayAt := StartNr, oDlg:ReSize() )
      
return nil


Sorry Antonio , that is not the point , i know how to avoid this error. I am wondering why this error is not yet reported , or am i wrong ?

With a array from three elements there is one chance on three that this error occurs with fwh808 . I have spent an half day to track down the cause and i hope it will be resolved in the next release

Frank
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Sat Oct 11, 2008 10:29 AM

Frank,

Adding ... COLUMNS 1 SIZES 100 we don't get an error here, but the rows sizes are not ok.

Is that the error that you mean ?

Please provide a concrete example to reproduce the error, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
XBROWSE : Error in refresh
Posted: Sat Oct 11, 2008 10:57 AM
Antonio Linares wrote:Frank,

Adding ... COLUMNS 1 SIZES 100 we don't get an error here, but the rows sizes are not ok.

Is that the error that you mean ?

Please provide a concrete example to reproduce the error, thanks


Adding ... COLUMNS 1 SIZES 100 we don't get an error here, but the rows sizes are not ok.

In mine main aplication it is also wat happens , ::rowheight has received a value 4 where it should be 18

In the example i receive

Application
===========
Path and name: b:\MCLS\fwh8.01xhbjuni\fwh8.08\objX\testxbrw.exe (32 bits)
Size: 1,671,168 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 10/11/08, 12:48:05
Error description: Error BASE/1004 Class: 'NIL' has no exported method: NESCAPEMENT
Args:
[ 1] = U

Stack Calls
===========
Called from: => NESCAPEMENT(0)
Called from: xbrowse.prg => FONTESC(7446)
Called from: xbrowse.prg => TXBRWCOLUMN:HEADERWIDTH(5676)
Called from: xbrowse.prg => TXBRWCOLUMN:ADJUST(5528)
Called from: xbrowse.prg => TXBROWSE:ADJUST(713)
Called from: xbrowse.prg => (b)TXBROWSE:TXBROWSE(397)
Called from: => TXBROWSE:ROWCOUNT(0)
Called from: xbrowse.prg => TXBROWSE:REFRESH(841)
Called from: xbrowse.prg => TXBRWCOLUMN:SORTARRAYDATA(7294)
Called from: xbrowse.prg => TXBROWSE:SETARRAY(3224)
Called from: xbrowse.prg => XBRWSETDATASOURCE(7613)
Called from: xbrowse.prg => XBROWSENEW(7484)
Called from: testxbrw.prg => MAIN(13)

It is compiled with fwh808 , only change in xbrowse is what you sugested

I don't understand why it gives here a error and not at your home

I looked in Xbrowse:new() :

METHOD New( oWnd ) CLASS TXBrowse

local hBmp

DEFAULT oWnd := GetWndDefault()

::oWnd := oWnd
tracelog(valtype(oWnd),oWnd!=nil)// ok , O and .T.
If oWnd != nil
::oFont := oWnd:oFont
Endif
tracelog(valtype(::oFont)) // U !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Why is oWnd:Font not set ??????

Frank
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Sat Oct 11, 2008 12:03 PM
Frank,

To avoid the escapement error you have to modify this function in xbrowse.prg:
static function FontEsc( oFont )

   local nEsc  := 0

   if oFont != nil .and. ValType( oFont:nEscapement ) == 'N'
      nEsc     := Abs( oFont:nEscapement )
   endif

return nEsc

You are right about oFont, it should not be nil. This could be a solution in Method PaintHeader(): (I have not tested it yet. I am on another computer right now)
...
   oFont   := ::oHeaderFont
   DEFAULT oFont := ::oBrw:oFont
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in refresh
Posted: Sat Oct 11, 2008 12:05 PM
Frank,

In your proposed code, this change is required:
...
If oWnd != nil
   if oWnd:oFont == nil
     oWnd:GetFont()
   endif
   ::oFont := oWnd:oFont
Endif 
...
regards, saludos

Antonio Linares
www.fivetechsoft.com