xBrowse and bClrStd

Post Reply
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

xBrowse and bClrStd

Post by Maurizio »

Good morning RAO

I have an array of colors and would like to apply it to the columns

this example works

Code: Select all

#include "fivewin.ch"
#include "xbrowse.ch"

function main()

  local oDlg, oBrw
  local aData    := { { "One", "Two" ,"_111"}, { "Three", "Four","_222" }, { "Five", "Six","_333" }  }

  DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE FWVERSION

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
         DATASOURCE aData AUTOCOLS ;
         CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrStd    := { || { CLR_BLACK, CLR_WHITE } }
      :aCols[ 1 ]:bClrStd  := { || { CLR_BLACK, CLR_HGREEN } }
      :aCols[ 2 ]:bClrStd  := { || { CLR_BLACK, CLR_RED} }
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
if I change with array ,it doesn't work

Code: Select all

function main()

  local oDlg, oBrw
  local aData    := { { "One", "Two" ,"_111"}, { "Three", "Four","_222" }, { "Five", "Six","_333" }  }

  lOCAL aColor  := {CLR_HGREEN , CLR_RED}

  DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE FWVERSION

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
         DATASOURCE aData AUTOCOLS ;
         CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrStd    := { || { CLR_BLACK, CLR_WHITE } }
      FOR n := 1 to 2
          :aCols[ n ]:bClrStd  := { || { CLR_BLACK,:aCols[n]  } }
      NEXT 
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
Maurizio
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: xBrowse and bClrStd

Post by nageswaragunupudi »

Whatever be the context, you should not use index variable inside a codeblock created inside the loop.
This is one fundamental rule we need to keep in mind since the clipper days.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: xBrowse and bClrStd

Post by Maurizio »

thanks RAO
there is workaraund for works with an array of color ?
I need to parameterize the colors of the columns .

Maurizio
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: xBrowse and bClrStd

Post by Enrico Maria Giordano »

At least, this is an error:

Code: Select all

:aCols[ n ]:bClrStd  := { || { CLR_BLACK,:aCols[n]  } }
Replace it with this other:

Code: Select all

:aCols[ n ]:bClrStd  := { || { CLR_BLACK,oBrw:aCols[n]  } }
EMG
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: xBrowse and bClrStd

Post by Maurizio »

Sorry Enrico I copied the wrong example,

Code: Select all

function main()

  local oDlg, oBrw
  local aData    := { { "One", "Two" ,"_111"}, { "Three", "Four","_222" }, { "Five", "Six","_333" }  }

  lOCAL aColor  := {CLR_HGREEN , CLR_RED} ,nColore

  DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE FWVERSION

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
         DATASOURCE aData AUTOCOLS ;
         CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrStd    := { || { CLR_BLACK, CLR_WHITE } }
          
      FOR n := 1 to 2
          :aCols[ n ]:bClrStd  :=   { || { CLR_BLACK,aColor[n]  } }
      NEXT 
     :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: xBrowse and bClrStd

Post by Enrico Maria Giordano »

Try this:

Code: Select all

#include "Fivewin.ch"


function main()

  local oDlg, oBrw
  local aData    := { { "One", "Two" ,"_111"}, { "Three", "Four","_222" }, { "Five", "Six","_333" }  }

  lOCAL aColor  := {CLR_HGREEN , CLR_RED}

  local n

  DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE FWVERSION

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
         DATASOURCE aData AUTOCOLS ;
         CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrStd    := { || { CLR_BLACK, CLR_WHITE } }
         
      FOR n := 1 to 2
          :aCols[ n ]:bClrStd  := MAKEBLOCK( aColor, n )
      NEXT
     :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil


STATIC FUNCTION MAKEBLOCK( aColor, n )

    RETURN { || { CLR_BLACK,aColor[n]  } }
EMG
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Re: xBrowse and bClrStd

Post by Maurizio »

Grazie Enrico ,

works as I wanted :D

Maurizio
Post Reply