Focal Point
[SOLVED] Hi-Lite keyword in a text string

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/213106913

December 17, 2009, 11:30 AM
jfr99
[SOLVED] Hi-Lite keyword in a text string
Hi All,

Using the following CAR file example:

-***********************************************
-*
-SET &KEYWORD = 'AUTO';
-*
TABLE FILE CAR
PRINT MODEL
BY COUNTRY
BY CAR
WHERE MODEL CONTAINS '&KEYWORD'
END
-************************************************

Is there a way to BOLD all the occurrences of the "KEYWORD" in a text string? So in this example, when I print MODEL, all of the occurences of "AUTO" would be bolded.

Thanks
Jim

This message has been edited. Last edited by: Kerry,


WebFocus 8.201M, Windows, App Studio
December 17, 2009, 11:38 AM
Tony A
Jim use GETOK to identify where the substring resides and then use judicial STYLE to highlight it.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
December 17, 2009, 11:45 AM
Francis Mariani
Here's one way, HTML output:

-*-- search2.fex: highlight the matched string
-SET &ECHO=ALL;

-SET &KEYWORD = 'DOOR';
-*-SET &KEYWORD = 'AUTO';

-SET &STRREP = '<span class=hi>' || &KEYWORD || '</span>';

TABLE FILE CAR
PRINT
COMPUTE MODELX/A100 =
-*STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, outstring);
  STRREP (24, MODEL, &KEYWORD.LENGTH, '&KEYWORD', &STRREP.LENGTH, '&STRREP', 100, 'A100');

BY COUNTRY
BY CAR
BY MODEL
WHERE MODEL CONTAINS '&KEYWORD'

ON TABLE HOLD AS H001 FORMAT HTMTABLE
END
-RUN

-HTMLFORM BEGIN
<html>
<head>
<style type="text/css">
.hi { color: red; }
</style>
</head>

<body>
!IBI.FIL.H001;
</body>
</html>
-HTMLFORM END

This will work for only the first string found in each row of the column.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 17, 2009, 11:49 AM
Tom Flynn
You are too fast Francis. Must have that code at the top of your favorites! Smiler

From last year:

Does anyone have a technique for coloring a portion of a string


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
December 29, 2009, 09:56 AM
jfr99
Hi Francis/Tom,

I used the examples you provided and came up with a solution that works great.

Thanks for your responses.

This post should be marked "SOLVED".

Jim


WebFocus 8.201M, Windows, App Studio