|
booth wrote: >HTML color values are red:blue:green. 0 to 255, or 00 to ff. How would >i make color Value 255:255:255 appear in a string as ff:ff:ff? Barbara told me someone already posted this solution. But since I couldn't find it anywhere in the archives, I'll post it anyways. One way to convert *several* numeric values to a string containing hex values is to use the C runtime library function "sprintf". Coding the prototype is a bit tricky. The trick to calling C functions with varying length argument list is to code OPTIONS(*NOPASS) for at least one of the arguments. (It has something to do with making sure the arguments are not passed in registers.) Check the following RPG program for an example of how to call "sprintf": H dftactgrp(*no) bnddir('QC2LE') D sprintfxxx pr 10i 0 extproc(*cwiden:'sprintf') D recvr * value D format * value options(*string) D red 3u 0 value D blue 3u 0 value D green 3u 0 value options(*nopass) D FMTXXX c '"#%2.2lx%2.2lx%2.2lx"' D recv s 50a D len s 10i 0 /free len = sprintfxxx(%addr(recv):FMTXXX:12:34:45); dsply ('|' + %subst(recv:1:len) + '|'); *inlr = *on; /end-free This working program displays the html color argument value: DSPLY |"#0c222d"| Note that it's important to save the length returned by "sprintf" and use it to substring the receiver variable since C likes to deal with null terminated strings. (Or, you could access the result value by coding "result=%str(%addr(recv));".) BTW, it should be noted that specifying colors within html is deprecated. You should be using style sheets instead. One of the methods for specifying color is "rgb(x,x,x)", where each x can be a decimal number from 0 to 255. That would simplify the problem significantly I would say. Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.