Some systems may use the older "indexed color" system which provided a color from a 16 x 16 palette numbered between 0-255. These numbers are incompatible with newer 4D tools like the Listbox, and thus need to be converted. Here's a simple method provided by Charlie Vass to the NUG for converting an indexed color value to an RGB longint:
$index_i:=$1 `Start with $index_i as the indexed color value
$chartColor_i:=CT Index to color ($index_i) ` Gets us a 0x00bbggrr value.
` Extract the RGB values. CT COLOR TO RGB doesn't do this the way we want. It returns values from 0..65535.
$red_i:=($chartColor_i & 0x00FF) ` get the red byte, 0..255
$green_i:=(($chartColor_i >> 8) & 0x00FF) ` get the green byte, 0..255
$blue_i:=(($chartColor_i >> 16) & 0x00FF) ` get the blue byte, 0..255
` Combine the RGB values to create a 4D RGB (0x00rrggbb) value
$rgb_i:=($red_i << 16)+($green_i << 8)+$blue_i `and now we have rgb_i with the longint color value
$0:=$rgb_i`return the RGB value