Reputation: 25
I want to create a generic program ie .i which i can call from a.w and which will change the browser colours depending on my conditions. How do i change the browser colours through .i ?
Upvotes: 0
Views: 1887
Reputation: 1217
If you need to have the coloring logic in an include, you may be able to do it with preprocessors. Create the include (e.g. colorbrs.i) like this:
ON ROW-DISPLAY OF {&Brs}
DO:
ASSIGN
{&Tbl}.{&Fld1}:FGCOLOR IN BROWSE {&Brs} = 12
{&Tbl}.{&Fld1}:BGCOLOR IN BROWSE {&Brs} = 9.
END.
The curly brackets are preprocessors. They get filled in at compile time. You define them in your .w like this:
{colorbrs.i &Brs=brsCust &Tbl=Customer &Fld1=Cust-Num}
When you compile the .w, the compiler will take the values from the include statement and fill them into the preprocessors in the include file.
Upvotes: 1
Reputation: 1498
I imagine you'd like to change the browse line colors. But I don't believe you'd be able to make an include for that, since you'll have to name the fields individually to do this the easy way. So let's suppose you have a browse called br-cust showing the customer table in which you're displaying customer num, name and credit-limit.
You need to add a row-display event to the browse, in which you'd say
ON ROW-DISPLAY OF BROWSE br-cust DO:
DEFINE VARIABLE iBgColor AS INTEGER NO-UNDO.
ASSIGN iBgColor = IF customer.credit-limit < 2000 THEN 9 ELSE 15
customer.cust-num :bgcolor in browse br-cust = iBgColor
customer.name :bgcolor in browse br-cust = iBgColor
customer.credit-limit:bgcolor in browse br-cust = iBgColor.
END.
This would work by changing the browse background color to red if credit limit was low (< 2000) or white if it's ok. If you'd like to change the Font color, use :color instead.
Now if you'd like to just give it any given browse the ability to change colors based on conditions, that would also be possible, but demand considerably more code. I'll try to post a solution as soon as I can, as I don't have access to Progress right now.
But I hope this helps.
Upvotes: 1