Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color coding content of calcuation fields

Status
Not open for further replies.

Zerosum

Technical User
May 25, 2006
4
US
Is it possible to vary the color of the text value of a calculation field according to what the calculation returns?

I have constructed a database of commodity price movements. One field "Direction" returns "up" or "down". Is there some way to color "up" blue and "down" red? Of course if "up" and "down" had their own fields, I could easily do this in Layout, but that's not what I want. I also have various calculation fields returning either the ansi character ? or ?. I would like to color code these as well.

It might be possible to accomplish this using container fields. However I understand that it is not possible to perform searches, or further calculations using the contents of container fields, so that rules them out.

I am new to FMP.
 
Yes, it's possible.

FM7/8, see the help file for Text Formatting Functions, with the RGB function you can play around.
Also with the TextColor function, the TextFont function,
the TextSize function, the TextStyleAdd function and the TextStyleRemove function.
Just pick one that will (can) do what you want.

FM < 7, use a container field that you put behind the desired field and change the color by calculation, f.i. with a Case statement. You will still have the possibilty to search on the 'front' field.
 
Thanks JeanW for your advice.

It'll take me some time to research all of these text formatting functions, but I appreciate the pointers.

I had hoped that one could simply append the text color parameters onto the original calculation;

so that the function for the Direction field:

Case(Change > 0; "up";Change = 0;"unch"; Change < 0;"down")

becomes

Case(Change > 0; "up";Change = 0;"unch"; Change < 0;"down"; Direction = "down"; TextColor("down";RGB(255;0;0); Direction = "up"; TextColor("up";RGB(0;0;255))

but FM ignores the added info. Either my syntax is wrong, or one cannot do this.

The container idea looks interesting. First I have to learn how one places a container field behind another field.

Again thanks for the info.
 
Try:

Case(Change > 0; "up";
Change = 0;"unch";
Change < 0;"down";
Direction = "down"; TextColor(Direction;RGB(255;0;0)); Direction = "up"; TextColor(Direction;RGB(0;0;255))
)
Down and up are 'results' of the Direction field, so, the Direction field has to be in the calc, not the value of that field.

The containertrick is for lower than FM7/8, but I still use it in 7 and 8. (has to do with age I think)

Make sure you have a repeating container field (like in your developer layout) with all the colors you want.
For each field where you want the background change in accordance with a value, you make a calc field, result container, unstored along these lines:

Case(
yourCalc = yourResult1;GetRepeatition(yourRepeatingColorField;yourRepeatingColorNrforThatValue);

yourCalc = yourResult2;GetRepeatition(yourRepeatingColorField;yourRepeatingColorNrforThatValue);

etc.
)

On your layout, make the basic field transparent, put the calc container on the layout, same dimentions as the basic field, send backwards until it is behind the basic field, and make it not accessible (take it out the taborder).
That's it.
The 'background' of your basic field will change in color in accordance with the result of the calc.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top