Focal Point
WebFOCUS Style Macros

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

April 11, 2013, 12:58 PM
Francis Mariani
WebFOCUS Style Macros
I never use Style macros, preferring to repeat the styling I require, but I wonder if a macro will help in the following situation:

I have a heading line that is generated by code (meaning the content can change). It is displayed in a HEADALIGN=BODY heading, with multiple items in the line.

Is it possible to use a macro to automate the font colour based on the content of the item?

123 <+0> (232) <+0> 985 <+0> (384)

I would like (232) and (384) to be in red.

Thanks,


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
April 11, 2013, 01:28 PM
FrankDutch
I think you can, but what we do is create a output file with a fex, hold that output and then include that in the second part of the fex.
The output file has code for the color, bold and other formatting issues.
I think you understand the idea.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

April 11, 2013, 01:57 PM
Francis Mariani
Frank,

I agree that your suggestion is the easiest approach.


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
April 11, 2013, 02:42 PM
MAdams1
Francis,

You could use the WHEN= in the style.

 


-SET &PRINTIT = IF &DEF EQ 1 THEN 'BY  LOWEST CAR.COMP.CAR NOPRINT' ELSE 'BY  LOWEST CAR.COMP.CAR '; 
 
TABLE FILE CAR
PRINT 
     CAR.CARREC.MODEL
     CAR.BODY.SEATS

&PRINTIT
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = endeflt,
$
TYPE=DATA,
     COLUMN=N2,
     STYLE=BOLD+UNDERLINE,
     COLOR='RED',
	 WRAP=4.00,
     WHEN=&DEF NE 1,
$
TYPE=TITLE,
     COLUMN=N4,
     STYLE=BOLD,
$
ENDSTYLE
END


 



WebFOCUS Server 8.1.05
Windows 2008 Server
WebFOCUS AppStudio 8.1.05
Windows 7 Professional
IE 11 and Chrome Version 43.0.2357.124 m.
Mostly HTML, PDF, Excel, and AHTML
April 12, 2013, 04:49 PM
nd
You could break string up into additional parameters using GETTOK, and then evaluate each parameter.

The macro itself doesn't seem to be very useful if you prefer to write the styles for each field. It seems more a shorthand for a preset definition than dynamic instructions.

  -SET &HEADLINE='123 <+0> (232) <+0> 985 <+0> (384)';
-SET &HFMT1=IF(GETTOK(&HEADLINE,&HEADLINE.LENGTH,1,'+',20,'A20V'))CONTAINS '(' THEN 1 ELSE 0;
-SET &HFMT2=IF(GETTOK(&HEADLINE,&HEADLINE.LENGTH,2,'+',20,'A20V'))CONTAINS '(' THEN 1 ELSE 0;
-SET &HFMT3=IF(GETTOK(&HEADLINE,&HEADLINE.LENGTH,3,'+',20,'A20V'))CONTAINS '(' THEN 1 ELSE 0;
-SET &HFMT4=IF(GETTOK(&HEADLINE,&HEADLINE.LENGTH,4,'+',20,'A20V'))CONTAINS '(' THEN 1 ELSE 0;
-SET &HFMT5=IF(GETTOK(&HEADLINE,&HEADLINE.LENGTH,5,'+',20,'A20V'))CONTAINS '(' THEN 1 ELSE 0;

TABLE FILE CAR
PRINT 
     CAR.CARREC.MODEL
     CAR.BODY.SEATS

HEADING
"&HEADLINE"

ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
$
TYPE=HEADING,ITEM=1,COLOR=ORANGE,STYLE=BOLD,WHEN=&HFMT1 EQ 1,$
TYPE=HEADING,ITEM=2,COLOR=ORANGE,STYLE=BOLD,WHEN=&HFMT2 EQ 1,$
TYPE=HEADING,ITEM=3,COLOR=ORANGE,STYLE=BOLD,WHEN=&HFMT3 EQ 1,$
TYPE=HEADING,ITEM=4,COLOR=ORANGE,STYLE=BOLD,WHEN=&HFMT4 EQ 1,$
TYPE=HEADING,ITEM=5,COLOR=ORANGE,STYLE=BOLD,WHEN=&HFMT4 EQ 1,$

ENDSTYLE
END



WF: WebFocus 7.7.03
Data: Oracle, MSSQL, DB2
OS: Windows
Output: HTML/AHTML,PDF,EXL2K FORMULA, COMT