[SOLVED] Does anyone have a technique for coloring a portion of a string
Standard styling will color whole strings, but I want to highlight where in a string a search match has occurred. eg we are searching for lmno and the result is
abcdefghijklmnopqrstuvwxyz
Has anyone come up with a nifty technique for doing this. I searched the forums and came up with diddley.
What would be awesome would be that it worked for html, pdf, exl2k, but HTML only would be enough.
Here's hoping
JohnThis message has been edited. Last edited by: Kerry,
Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2 Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
December 23, 2008, 10:21 AM
Tom Flynn
Hi John,
THANKS!! for getting my mind working this morning!!! Appreciate it...
You'll have to play around with the POSIT stuff when the string is in different places, AND, I couldn't get the dynamic field format to work in a DEFINE, BUT, this works:
-SET &SEARCH = 'lmno';
-SET &LEN = &SEARCH.LENGTH;
DEFINE FILE CAR
COL1/A26 = 'abcdefghijklmnopqrstuvwxyz';
COL1_A1/I2 = POSIT(COL1, 26, '&SEARCH', &LEN , 'I2');
COL1_A2/A4 = SUBSTR(26, COL1, COL1_A1, COL1_A1+3, 4, COL1_A2);
-******************************************************************
COL1_B1/I2 = IF COL1_A1 EQ 1 THEN &LEN ELSE COL1_A1 - 1;
COL1_C1/I2 = COL1_B1 + &LEN;
COL1_D1/I2 = IF COL1_C1 EQ 26 THEN 26 ELSE 26 - COL1_C1;
XFMT1/A8 = IF COL1_B1 EQ 0 THEN 'A' || EDIT(COL1_D1)
ELSE 'A' || EDIT(COL1_B1) ;
XFMT2/A8 = IF COL1_D1 EQ 0 THEN 'A' || EDIT(COL1_B1)
ELSE 'A' || EDIT(COL1_D1) ;
END
TABLE FILE CAR
SUM
XFMT1
BY COUNTRY NOPRINT
IF RECORDLIMIT EQ 1
ON TABLE SAVE
END
-RUN
-READ SAVE &XFMT1.A8.
-TYPE &XFMT1
TABLE FILE CAR
SUM
XFMT2
BY COUNTRY NOPRINT
IF RECORDLIMIT EQ 1
ON TABLE SAVE
END
-RUN
-READ SAVE &XFMT2.A8.
-TYPE &XFMT2
TABLE FILE CAR
SUM
COL1_A1
COL1_A2
COL1_B1
COL1_C1
COL1_D1
XFMT1
XFMT2
COMPUTE COL1_A3/&XFMT1 = SUBSTR(26, COL1, 1, COL1_B1, COL1_B1, COL1_A3);
COMPUTE COL1_A4/&XFMT2 = SUBSTR(26, COL1, COL1_C1, 26 , COL1_D1, COL1_A4);
COMPUTE SHOW_DATA/A300 = '<FONT color="black">' | COL1_A3 | '</FONT>' | '<FONT color="red">' | COL1_A2 | '</FONT>' | '<FONT color="black">' | COL1_A4 | '</FONT>';
BY COUNTRY
END
-EXIT
Ironically Francis' technique seems simpler but if you uppercase the string in order to do a case unsensitive search you still have to use Tom's technique to reinsert into the original not uppercased string.
I'm thinking as well along lines of letting wf do the work of generating a red class by putting a dummy entry into the styling sheet and using that in the class statements. That avoids the HTMLFORM but could be a bit risky seeing that the names of the styles .x1, .x2 etc could change.
Thanks for your ideas - both of you.
Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2 Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
December 23, 2008, 12:55 PM
Tom Flynn
John,
Glad it is working out for you. Both ideas also work for EXCEL with:
BTW if you want PDF look alike with html try FORMAT DHTML.
Tried to do this
TYPE=DATA,COLOR=RED,WHEN=1 EQ 2, $
Hoping wf would define a class that it never uses but for a class to be in the HTML generated it needs to be referenced so it looks like -HTMLFORM it is.
Regards
John
Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2 Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo