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!

Setting background color from composite decimal value

Status
Not open for further replies.

Anastasis

MIS
Dec 15, 2004
27
GB
I need to be able to set the background color of some crosstab cells from the colour values stored in a table. Yes, I can use the Color(r,g,b) function, but my color number is a single composite color value.

For example, I have one value which = 5592490

This equates to hexadecimal 5555AA (r:55, g:55, b:AA)
which equates to an RGB Color value of 85, 85, 170

but I don't know how in CR procedural code to do that.

I have tried the following:

Color (Remainder ({MyTable.MyColor},256*256*256),
(Remainder ({MyTable.MyColor},256*256)),
(Remainder ({MyTable.MyColor},256)))

but although the syntax is correct, I get an error saying a value is over 255. On my example above I think the calculation is correct, but maybe it is failing on another value (e.g. 255 = R:0 G:0 B:255)?

In Delphi I could write this as:

R := Color and $255;
G := (Color and $ff00) shr 8;
B := (Color and $ff0000) shr 16;

where R, G and B are integers, $ prefix is for hexadecimal and shr is performing bitwise comparison (something which CR10 I think cannot do).

Thanks in advance for any help with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top