` RGB to html/xml/css/xslt stream (Stephen Bottomley ) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Par2: RGB to html/xml/css/xslt stream
2002-07-09 -- Stephen Bottomley
 
Decimal to Hex courtesy of Andrew Ireland Function returns a value usable to parse out to a html/xml/css/xslt stream MAP RgbToHex(LONG lRed = 0,LONG lGreen = 0,LONG lBlue = 0),STRING DecToHex(LONG lDecVal,LONG Flag = 0),STRING END RgbToHex(LONG lRed = 0,LONG lGreen = 0,LONG lBlue = 0) RetVal CSTRING(9) SaveRed STRING(8) SaveGreen STRING(8) SaveBlue STRING(8) CODE SaveRed = Dec2Hex(lRed) SaveGreen = Dec2Hex(lGreen) SaveBlue = Dec2Hex(lBlue) Retval = SaveRed[7 : 8] & SaveGreen[7 : 8] & SaveBlue[7 : 8] return(RetVal) DecToHex(LONG lDecVal,LONG Flag = 0) Counter BYTE HexDig STRING('0123456789ABCDEF') DecVal LONG HexMap GROUP,PRE(),OVER(DecVal) b4 BYTE b3 BYTE b2 BYTE b1 BYTE END HexVal STRING(8),AUTO CODE DecVal = lDecVal HexVal[1] = HexDig[BSHIFT(b1, -4)+1] HexVal[2] = HexDig[BAND(b1, 0Fh)+1] HexVal[3] = HexDig[BSHIFT(b2, -4)+1] HexVal[4] = HexDig[BAND(b2, 0Fh)+1] HexVal[5] = HexDig[BSHIFT(b3, -4)+1] HexVal[6] = HexDig[BAND(b3, 0Fh)+1] HexVal[7] = HexDig[BSHIFT(b4, -4)+1] HexVal[8] = HexDig[BAND(b4, 0Fh)+1] if band(Flag,Dec2Hex:RemoveZeros) loop Counter = 1 to len(clip(HexVal)) - 1 if HexVal[Counter] <> '0' break . . HexVal = HexVal[Counter : len(HexVal)] . if band(Flag,Dec2Hex:Lower) return(lower(clip(HexVal))) else return(clip(HexVal)) . here is DAB's version of that function: ToHex FUNCTION(LONG L) PS STRING('0123456789ABCDEF'),STATIC CODE RETURN CHOOSE(L < 16,PS[L+1],ToHex(L/16) & ToHex(L%16))


Today is November 21, 2024, 3:37 am
This article has been viewed 35216 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: