KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Convert 4D Color Constant to Decimal
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: December 28, 2020

When performing database upgrades, it may be beneficial to find the decimal value equivalent of a 4D color constant. The below method converts a 4D color constant into decimal.

Example In: Yellow or 1
Example Out: 16776960

//---------------------------------------------------------------------------
//METHOD NAME: UTIL_ConstantToDecimal
//DESCRIPTION: Converts 4D color constants to decimal
//INPUT PARAMETER:
//$1 (LONGINT) - 4D Color Constant
//OUTPUT:
//$0 (LONGINT) - Decimal value equivalent
//---------------------------------------------------------------------------

C_LONGINT($1;$0;$colorConstant_l)
ARRAY LONGINT($colorValue_a;255)

$colorConstant_l:=$1

$colorValue_a{0}:=16777215
$colorValue_a{1}:=16776960
$colorValue_a{2}:=16737792
$colorValue_a{3}:=15597568
$colorValue_a{4}:=16711833
$colorValue_a{5}:=153
$colorValue_a{6}:=255
$colorValue_a{7}:=39423
$colorValue_a{8}:=47872
$colorValue_a{9}:=39168
$colorValue_a{10}:=6697728
$colorValue_a{11}:=4473924
$colorValue_a{12}:=14540253
$colorValue_a{13}:=10053120
$colorValue_a{14}:=11184810
$colorValue_a{15}:=0
$colorValue_a{16}:=16711774
$colorValue_a{17}:=16712790
$colorValue_a{18}:=16711752
$colorValue_a{19}:=16711755
$colorValue_a{20}:=16711730
$colorValue_a{21}:=16711719
$colorValue_a{22}:=16711708
$colorValue_a{23}:=16711697
$colorValue_a{24}:=16711686
$colorValue_a{25}:=16712704
$colorValue_a{26}:=16715520
$colorValue_a{27}:=16718336
$colorValue_a{28}:=16721152
$colorValue_a{29}:=16723968
$colorValue_a{30}:=16726784
$colorValue_a{31}:=16729600
$colorValue_a{32}:=16731392
$colorValue_a{33}:=16733184
$colorValue_a{34}:=16734976
$colorValue_a{35}:=16736768
$colorValue_a{36}:=16738560
$colorValue_a{37}:=16740867
$colorValue_a{38}:=16743428
$colorValue_a{39}:=16744962
$colorValue_a{40}:=16747014
$colorValue_a{41}:=16749059
$colorValue_a{42}:=16750850
$colorValue_a{43}:=16752643
$colorValue_a{44}:=16752384
$colorValue_a{45}:=16756240
$colorValue_a{46}:=16756999
$colorValue_a{47}:=16758788
$colorValue_a{48}:=16760832
$colorValue_a{49}:=16762628
$colorValue_a{50}:=16764416
$colorValue_a{51}:=16766720
$colorValue_a{52}:=16768771
$colorValue_a{53}:=16770565
$colorValue_a{54}:=16772874
$colorValue_a{55}:=16774660
$colorValue_a{56}:=16776454
$colorValue_a{57}:=16383744
$colorValue_a{58}:=15924996
$colorValue_a{59}:=15466240
$colorValue_a{60}:=14876416
$colorValue_a{61}:=13893376
$colorValue_a{62}:=13303552
$colorValue_a{63}:=12844800
$colorValue_a{64}:=12386048
$colorValue_a{65}:=10944256
$colorValue_a{66}:=9502464
$colorValue_a{67}:=8060672
$colorValue_a{68}:=6618880
$colorValue_a{69}:=5242624
$colorValue_a{70}:=3997443
$colorValue_a{71}:=851712
$colorValue_a{72}:=261900
$colorValue_a{73}:=327459
$colorValue_a{74}:=65333
$colorValue_a{75}:=65355
$colorValue_a{76}:=65376
$colorValue_a{77}:=65398
$colorValue_a{78}:=65420
$colorValue_a{79}:=65447
$colorValue_a{80}:=65447
$colorValue_a{81}:=65457
$colorValue_a{82}:=65467
$colorValue_a{83}:=65477
$colorValue_a{84}:=65488
$colorValue_a{85}:=65498
$colorValue_a{86}:=65508
$colorValue_a{87}:=65518
$colorValue_a{88}:=65528
$colorValue_a{89}:=65023
$colorValue_a{90}:=62463
$colorValue_a{91}:=59903
$colorValue_a{92}:=57599
$colorValue_a{93}:=54783
$colorValue_a{94}:=52223
$colorValue_a{95}:=49663
$colorValue_a{96}:=46335
$colorValue_a{97}:=41471
$colorValue_a{98}:=36607
$colorValue_a{99}:=31999
$colorValue_a{100}:=27135
$colorValue_a{101}:=22271
$colorValue_a{102}:=17407
$colorValue_a{103}:=76031
$colorValue_a{104}:=7935
$colorValue_a{105}:=3071
$colorValue_a{106}:=459007
$colorValue_a{107}:=1638655
$colorValue_a{108}:=2883839
$colorValue_a{109}:=4129023
$colorValue_a{110}:=5374207
$colorValue_a{111}:=6619391
$colorValue_a{112}:=7864575
$colorValue_a{113}:=9109759
$colorValue_a{114}:=10354943
$colorValue_a{115}:=11600127
$colorValue_a{116}:=12845311
$colorValue_a{117}:=14090495
$colorValue_a{118}:=15335679
$colorValue_a{119}:=16580863
$colorValue_a{120}:=16712687
$colorValue_a{121}:=16711900
$colorValue_a{122}:=16711881
$colorValue_a{123}:=16711862
$colorValue_a{124}:=16711843
$colorValue_a{125}:=16711824
$colorValue_a{126}:=16711805
$colorValue_a{127}:=16711786
$colorValue_a{128}:=16769248
$colorValue_a{129}:=16761024
$colorValue_a{130}:=16752800
$colorValue_a{131}:=16744319
$colorValue_a{132}:=16736095
$colorValue_a{133}:=16728128
$colorValue_a{134}:=16719904
$colorValue_a{135}:=16711680
$colorValue_a{136}:=15470336
$colorValue_a{137}:=14155776
$colorValue_a{138}:=13565952
$colorValue_a{139}:=11534336
$colorValue_a{140}:=10223616
$colorValue_a{141}:=8912896
$colorValue_a{142}:=7602176
$colorValue_a{143}:=6291456
$colorValue_a{144}:=16773343
$colorValue_a{145}:=16769216
$colorValue_a{146}:=16764832
$colorValue_a{147}:=16760447
$colorValue_a{148}:=16756831
$colorValue_a{149}:=16752960
$colorValue_a{150}:=16748832
$colorValue_a{151}:=16744704
$colorValue_a{152}:=15496960
$colorValue_a{153}:=14183680
$colorValue_a{154}:=12870400
$colorValue_a{155}:=11557120
$colorValue_a{156}:=10244608
$colorValue_a{157}:=8930560
$colorValue_a{158}:=7617280
$colorValue_a{159}:=6303744
$colorValue_a{160}:=16777183
$colorValue_a{161}:=16777152
$colorValue_a{162}:=16777120
$colorValue_a{163}:=16777087
$colorValue_a{164}:=16711519
$colorValue_a{165}:=16711488
$colorValue_a{166}:=16711456
$colorValue_a{167}:=16711424
$colorValue_a{168}:=15395840
$colorValue_a{169}:=14079744
$colorValue_a{170}:=12763904
$colorValue_a{171}:=11448064
$colorValue_a{172}:=10395392
$colorValue_a{173}:=8882176
$colorValue_a{174}:=7566336
$colorValue_a{175}:=6250496
$colorValue_a{176}:=14876639
$colorValue_a{177}:=12976064
$colorValue_a{178}:=11009952
$colorValue_a{179}:=9043839
$colorValue_a{180}:=7143263
$colorValue_a{181}:=5242688
$colorValue_a{182}:=3276576
$colorValue_a{183}:=1310464
$colorValue_a{184}:=1240064
$colorValue_a{185}:=1103872
$colorValue_a{186}:=1033216
$colorValue_a{187}:=897024
$colorValue_a{188}:=826368
$colorValue_a{189}:=690176
$colorValue_a{190}:=619520
$colorValue_a{191}:=483328
$colorValue_a{192}:=14680063
$colorValue_a{193}:=12648447
$colorValue_a{194}:=10551295
$colorValue_a{195}:=8388351
$colorValue_a{196}:=6291199
$colorValue_a{197}:=4259583
$colorValue_a{198}:=2162175
$colorValue_a{199}:=65023
$colorValue_a{200}:=59884
$colorValue_a{201}:=55000
$colorValue_a{202}:=49860
$colorValue_a{203}:=44720
$colorValue_a{204}:=39836
$colorValue_a{205}:=34696
$colorValue_a{206}:=29556
$colorValue_a{207}:=24416
$colorValue_a{208}:=14673151
$colorValue_a{209}:=12634879
$colorValue_a{210}:=10530815
$colorValue_a{211}:=8360959
$colorValue_a{212}:=6256895
$colorValue_a{213}:=4218623
$colorValue_a{214}:=2114303
$colorValue_a{215}:=10239
$colorValue_a{216}:=9452
$colorValue_a{217}:=8664
$colorValue_a{218}:=8399
$colorValue_a{219}:=7088
$colorValue_a{220}:=6300
$colorValue_a{221}:=5512
$colorValue_a{222}:=4724
$colorValue_a{223}:=3680
$colorValue_a{224}:=16769023
$colorValue_a{225}:=16761087
$colorValue_a{226}:=16752895
$colorValue_a{227}:=16744447
$colorValue_a{228}:=16736255
$colorValue_a{229}:=16728319
$colorValue_a{230}:=16720127
$colorValue_a{231}:=16711935
$colorValue_a{232}:=15401196
$colorValue_a{233}:=14090456
$colorValue_a{234}:=13566159
$colorValue_a{235}:=11534512
$colorValue_a{236}:=10223772
$colorValue_a{237}:=8913032
$colorValue_a{238}:=7602292
$colorValue_a{239}:=6291552
$colorValue_a{240}:=16777215
$colorValue_a{241}:=15658734
$colorValue_a{242}:=14540253
$colorValue_a{243}:=13421772
$colorValue_a{244}:=12632256
$colorValue_a{245}:=11184810
$colorValue_a{246}:=10066329
$colorValue_a{247}:=8947848
$colorValue_a{248}:=7829367
$colorValue_a{249}:=6710886
$colorValue_a{250}:=5592405
$colorValue_a{251}:=4210752
$colorValue_a{252}:=3355443
$colorValue_a{253}:=2236962
$colorValue_a{254}:=1118481
$colorValue_a{255}:=0

$0:=$colorValue_a{$colorConstant_l}

Example method call.
$colorDecmal:=UTIL_ConstantToDecimal (Yellow)