FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oBrw:bClrStd error in 16.04
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
oBrw:bClrStd error in 16.04
Posted: Tue May 17, 2016 11:46 AM
Hi,

I was using it in 16.02 without any error.
Code (fw): Select all Collapse
  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 (fw): Select all Collapse
   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.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: oBrw:bClrStd error in 16.04
Posted: Tue May 17, 2016 01: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 (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: oBrw:bClrStd error in 16.04
Posted: Tue May 17, 2016 01:43 PM

Thank you mr. Rao,

It is working now.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion