oBrw:bClrStd error in 16.04

oBrw:bClrStd error in 16.04

Postby Horizon » Tue May 17, 2016 11:46 am

Hi,

I was using it in 16.02 without any error.
Code: Select all  Expand view
 oBrw:bClrStd   := { || { CLR_BLACK, If( oBrw:aRow[6] <> oBrw:aRow[13], RGB(255,0,0),GetSysColor( 5 )  ) } }    // Line 569
 


But it gives an error in 16.04.
Code: Select all  Expand view
  Error description: Error BASE/1132  Bound error: array access
   Args:
     [   1] = A   { ... } length: 0
     [   2] = N   1

Stack Calls
===========
   Called from:  => ARRAY:__OPARRAYINDEX( 0 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 653 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:AROW( 0 )
   Called from: .\Kasa.prg => (b)GET_NEW_KASA( 569 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:CREATEBARGET( 12452 )
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:ADJUST( 10475 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:ADJUST( 1284 )


Any help?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: oBrw:bClrStd error in 16.04

Postby nageswaragunupudi » Tue May 17, 2016 1:10 pm

This must have happened when browsing an empty array.

Please make this modification in xbrowse.prg:
Please locate METHOD CreateBarGet() CLASS TXBrwColumn ( Line 12450 )
Code: Select all  Expand view
METHOD CreateBarGet() CLASS  TXBrwColumn

   local aColors  := Eval( ::bClrEdit )
   local lRight   := .f.

   if ::uBarGetVal != nil .and. ::oBarGet == nil
      lRight      := ( ValType( ::uBarGetVal ) == 'N' )
 

Move assignment of aColors from declaration to after the if condition like this:
Code: Select all  Expand view
METHOD CreateBarGet() CLASS  TXBrwColumn

   local aColors  //:= Eval( ::bClrEdit )
   local lRight   := .f.

   if ::uBarGetVal != nil .and. ::oBarGet == nil
      aColors     := Eval( ::bClrEdit ) // Inserted
      lRight      := ( ValType( ::uBarGetVal ) == 'N' )

 


With this correction, you should not get this error.

But we have a general advice about the definition of bClrStd
Your definition:
Code: Select all  Expand view
oBrw:bClrStd   := { || { CLR_BLACK, If( oBrw:aRow[6] <> oBrw:aRow[13], RGB(255,0,0),GetSysColor( 5 )  ) } }

This assumes that bClrStd will never be evaluated when the Array is empty. This is not a very safe assumption.
It is better to code this in a safe manner like this
Code: Select all  Expand view
oBrw:bClrStd   := { || { CLR_BLACK, If( oBrw:nLen > 0 .and. oBrw:aRow[6] <> oBrw:aRow[13], RGB(255,0,0),GetSysColor( 5 )  ) } }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: oBrw:bClrStd error in 16.04

Postby Horizon » Tue May 17, 2016 1:43 pm

Thank you mr. Rao,

It is working now.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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