Problem with using TBColumn:ColorBlock - Clipper

This is a discussion on Problem with using TBColumn:ColorBlock - Clipper ; Dear Friends, Enviro: Clipper 5.2e I'm trying to 'color' a cell in column 'n' of a TBowse of a database based on the value in column '1' of that same record in the TBrowse. The following compiles and runs but ...

+ Reply to Thread
Results 1 to 3 of 3

Problem with using TBColumn:ColorBlock

  1. Default Problem with using TBColumn:ColorBlock

    Dear Friends,

    Enviro: Clipper 5.2e

    I'm trying to 'color' a cell in column 'n' of a TBowse of a database
    based on the value in column '1' of that same record in the TBrowse.

    The following compiles and runs but shows no difference in color ( 'B'
    is the main browse block):

    COL = TBCOLUMNNEW("Amount Owed",{||ITEMAMT-PAYAMT})
    COL:COLORBLOCK :=
    {|X|IF(EVAL(B:GETCOLUMN(1):BLOCK)==CHR(255),{5,5},{7,8})}
    B:ADDCOLUMN(COL)
    LPADCOL = B:COLCOUNT
    B:GETCOLUMN(LPADCOL):WIDTH := 11
    B:GETCOLUMN(LPADCOL):PICTURE := "@Z ########.##"

    btw, the {5,5} and {7,8} color strings are decidely different but this
    cell always shows as color {7,8}. I wish this 'totalling line' (marked by
    chr(255) in column 1 to show a different color (i.e., {5,5} in this column
    'n' only)

    another btw: I changed getcolumn(1) to getcolumn(b:1) and got a crash.

    Question: How can I make the color of a column cell depend on the value in
    a *different* column in the same record ??

    TIA,

    -Mel Smith




  2. Default Re: Problem with using TBColumn:ColorBlock

    Mel

    Does you Colorspec have 8 elements or more??

    You might show us the code for Column #1 to see what happens there
    Also if using Clipper 5.3 you need to return an array with 4 values { 1, 2, 3,
    4 }

    One way is to put the test in a function (easier to debug as well<g>)
    Eg
    COL = TBCOLUMNNEW("Amount Owed",{||ITEMAMT-PAYAMT})
    COL:COLORBLOCK := {|| ColourMe( B ) }

    Function ColourMe( oTB )
    local oCol
    local anArray

    anArray := { 7, 8 }
    oCol := oTB:GetColumn(1)
    IF Eval( oCol:Block ) = CHR(255)
    anArray := { 5, 5 }
    ENDIF
    RETURN anArray

    HTH
    Steve



  3. Default Re: Problem with using TBColumn:ColorBlock

    Stephen said

    > Does you Colorspec have 8 elements or more??


    Yes, I have nine elements

    > You might show us the code for Column #1 to see what happens there


    Arrgggg ( (I'm very embarassed ..)
    I just looked at the col 1 definition and am now very embarassed ! I had
    the column 1 block specified wrongly as Picture "###" rather than Picture
    "XXX"

    Then when I changed my eval block to check for chr(255) $
    Eval(....,etc), it worked correctly.

    Sorry to put you to all that work. I fussed and fussed and fussed
    *until* your note prompted me to look again at the definition for column
    1 -- and then saw my error

    > Also if using Clipper 5.3 you need to return an array with 4 values { 1,

    2, 3,
    > 4 }


    No, I'm using 5.2e


    > One way is to put the test in a function (easier to debug as well<g>)
    > Eg
    > COL = TBCOLUMNNEW("Amount Owed",{||ITEMAMT-PAYAMT})
    > COL:COLORBLOCK := {|| ColourMe( B ) }
    >
    > Function ColourMe( oTB )
    > local oCol
    > local anArray
    >
    > anArray := { 7, 8 }
    > oCol := oTB:GetColumn(1)
    > IF Eval( oCol:Block ) = CHR(255)
    > anArray := { 5, 5 }
    > ENDIF
    > RETURN anArray
    >
    > HTH
    > Steve
    >


    This is also a good way for me to use more complex code for later
    purposes.

    So, it now works perfectly and I Thank yo very much Stephen !

    -Mel Smith




+ Reply to Thread

Similar Threads

  1. TBCOLUMN colorBlock bug
    By Application Development in forum xharbour
    Replies: 2
    Last Post: 10-18-2007, 11:17 AM
  2. Replies: 4
    Last Post: 10-24-2006, 08:35 PM
  3. problem to SELECT using Microsoft Access (posted again,problem with reading)
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 05-14-2006, 08:01 AM
  4. Replies: 0
    Last Post: 10-19-2005, 02:43 AM
  5. Disassembly problem-Gateway & Boot-Block Bios Problem
    By Application Development in forum Hardware
    Replies: 0
    Last Post: 07-05-2004, 07:55 AM