XBROWSE : Error in refresh

XBROWSE : Error in refresh

Postby demont frank » Thu Oct 09, 2008 9: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

Code: Select all  Expand view
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)

Code: Select all  Expand view
// 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)
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Re: XBROWSE : Error in refresh

Postby demont frank » 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

Code: Select all  Expand view
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)

Code: Select all  Expand view
// 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 :

Code: Select all  Expand view
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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Oct 09, 2008 12:02 pm

Frank,

This example is working fine here:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby demont frank » Thu Oct 09, 2008 3:41 pm

Antonio Linares wrote:Frank,

This example is working fine here:
Code: Select all  Expand view
#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 :
Code: Select all  Expand view
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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Antonio Linares » Thu Oct 09, 2008 6:35 pm

Frank,

> I changed your example.

Please provide my modified example to test it here, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Oct 09, 2008 6:40 pm

Frank,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby demont frank » Fri Oct 10, 2008 6: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 :

Code: Select all  Expand view
ON INIT ( StartNr := ASCAN(oBrw:aArrayData,"three") , oBrw:nArrayAt := StartNr, oDlg:ReSize() )
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

ERROR NOT SOLVED

Postby demont frank » Sat Oct 11, 2008 4:52 am

Antonio Linares wrote:Frank,

This may help:
Code: Select all  Expand view
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

Code: Select all  Expand view
      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 :


Code: Select all  Expand view
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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Antonio Linares » Sat Oct 11, 2008 7:22 am

Frank,

Try it this way:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby demont frank » Sat Oct 11, 2008 8:43 am

Antonio Linares wrote:Frank,

Try it this way:
Code: Select all  Expand view
#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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby demont frank » 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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Antonio Linares » Sat Oct 11, 2008 12:03 pm

Frank,

To avoid the escapement error you have to modify this function in xbrowse.prg:
Code: Select all  Expand view
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)
Code: Select all  Expand view
...
   oFont   := ::oHeaderFont
   DEFAULT oFont := ::oBrw:oFont
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sat Oct 11, 2008 12:05 pm

Frank,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 61 guests