Announcement

Collapse
No announcement yet.

doubt with macro sc_field_color : event OnRecord for a grid

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • doubt with macro sc_field_color : event OnRecord for a grid

    I have a grid with column names a_4, a_4_1_2, a_5 and so on.
    Values are integer, and I would like to print out the value only if it is not zero (if zero, set the field color to white).
    I have problems with macro sc_field_color.
    I put the following code inside the OnRecord event and it works .

    ------------------------
    if ({a_4}<>0)
    {
    sc_field_color("a_4", "#000000");
    }
    else {
    sc_field_color("a_4", "#FFFFFF");
    };
    ------------------------

    If I try to use a variable to refer to the field name, I make some mistake, as the following code
    ------------------
    $campo="a_4";

    if ({$campo}<>0)
    {
    sc_field_color("$campo", "#000000");
    }
    else {
    sc_field_color("$campo", "#FFFFFF");
    };
    -------------------

    I guess it is a stupid error from myself, I tried any kind of combination with or without the ".

    The idea then, is to make a check for any field in the grid, using an array.
    Thanks in advance for any suggestion

  • #2
    Never done this but {$campo} should be just $campo, because there is no field name {$campo}. $campo should contain the fieldname, not sure if it needs to contain {} too.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Albert, thanks for the reply.
      Neither case worked actually. I ended up writing a method without variables.
      It is a pity, because I would like to generalize . Meanwhile, this is how i worked around.
      As I said, it is my lack of knowledge with sc for sure, not a bug.

      Comment

      Working...
      X