xBrowse and bClrStd

xBrowse and bClrStd

Postby Maurizio » Mon Sep 07, 2020 10:33 am

Good morning RAO

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

this example works

Code: Select all  Expand view  RUN
#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  Expand view  RUN
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
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Re: xBrowse and bClrStd

Postby nageswaragunupudi » Mon Sep 07, 2020 11:06 am

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
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse and bClrStd

Postby Maurizio » Mon Sep 07, 2020 12:32 pm

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

Maurizio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Re: xBrowse and bClrStd

Postby Enrico Maria Giordano » Mon Sep 07, 2020 12:59 pm

At least, this is an error:

Code: Select all  Expand view  RUN
:aCols[ n ]:bClrStd  := { || { CLR_BLACK,:aCols[n]  } }


Replace it with this other:

Code: Select all  Expand view  RUN
:aCols[ n ]:bClrStd  := { || { CLR_BLACK,oBrw:aCols[n]  } }


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

Re: xBrowse and bClrStd

Postby Maurizio » Mon Sep 07, 2020 1:09 pm

Sorry Enrico I copied the wrong example,
Code: Select all  Expand view  RUN
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
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Re: xBrowse and bClrStd

Postby Enrico Maria Giordano » Mon Sep 07, 2020 1:16 pm

Try this:

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: xBrowse and bClrStd

Postby Maurizio » Mon Sep 07, 2020 1:30 pm

Grazie Enrico ,

works as I wanted :D

Maurizio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests