Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

openedge - Progress 4gl - change font color of specific values while exporting temp table to .html file

I have a situation where I would like to change the font color of the specific values in a temp table while exporting to .html using progress 4gl.

Below is the program I wrote to output the values to .html file. Please help me to solve this.

OUTPUT TO VALUE ("JITS_UserMonitorJITS_UserMonitor.html").
PUT UNFORMATTED "<TABLE
                    style=' border: 1px solid black;border-collapse: collapse;width:100%; font-family: arial, sans-serif;'>
                        <tr style='background-color: #dddddd; text-align: center' >
                            <th style=' border: 1px solid black;border-collapse: collapse;'>USER Name</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>USER Full Name</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>USER CREATE Date</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>USER LastLogin Date</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>Need Disable</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>Need DELETE</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>DISABLE Status</th>
                            <th style=' border: 1px solid black;border-collapse: collapse;'>LAST Logon Days</th>
                        </tr>
                    " SKIP.
    FOR EACH tt_data WHERE tt_data.tt_needdisable EQ TRUE OR 
            tt_data.tt_needdelete EQ TRUE NO-LOCK BY tt_data.tt_days DESC:
        PUT UNFORMATTED SUBSTITUTE ("   <tr style = 'text-align: center'>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&1</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&2</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&3</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&4</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&5</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&6</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&7</td>
                                                <td style=' border: 1px solid black;border-collapse: collapse;'>&8</td>
                                            </tr>",
                                                tt_data.tt_userid,
                                                tt_data.tt_fullname,
                                                tt_data.tt_createddate,
                                                tt_data.tt_lastlogon, 
                                                tt_data.tt_needdisable,
                                                tt_data.tt_needdelete,
                                                tt_data.tt_disable,
                                                tt_data.tt_days) SKIP.
    END.    
PUT UNFORMATTED "</TABLE>" SKIP.
OUTPUT CLOSE.
question from:https://stackoverflow.com/questions/65662108/progress-4gl-change-font-color-of-specific-values-while-exporting-temp-table-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use IF inside your statement. Something like this:

PUT UNFORMATTED 'This will output ' (IF TRUE THEN "something" ELSE "nothing").

That will output

This will output something

TRUE can be changed to any check you want to.

However, since you use SUBSTITUTE you could consider adding a variable for the color.

PUT UNFORMATTED SUBSTITUTE ("   <tr style = 'text-align: center'>
                                            <td style=' border: 1px solid black;border-collapse: collapse;color:&9;'>&1</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&2</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&3</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&4</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&5</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&6</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&7</td>
                                            <td style=' border: 1px solid black;border-collapse: collapse;'>&8</td>
                                        </tr>",
                                            tt_data.tt_userid,
                                            tt_data.tt_fullname,
                                            tt_data.tt_createddate,
                                            tt_data.tt_lastlogon, 
                                            tt_data.tt_needdisable,
                                            tt_data.tt_needdelete,
                                            tt_data.tt_disable,
                                            tt_data.tt_days,
                                            color
) SKIP.

And then your program needs to set the color variable based on whatever logic you need.

You could also match "normal" variables and the &-syntax of SUBSTITUTE:

DEFINE VARIABLE cColor AS CHARACTER   NO-UNDO.
DEFINE VARIABLE iInt   AS INTEGER     NO-UNDO.

cColor = "black".
iInt = 12.

MESSAGE  SUBSTITUTE("This is a color " + cColor + " and a number &1", iInt).

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...