IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    Can I put conditions (IF, tags) in a Style Sheet?
Go
New
Search
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Gold member
Posted
Is it possible to put conditions inside a style sheet?

Ex:
ON TABLE SET STYLE *
-IF &LOGO EQ 'PDP' THEN GOTO PDPHEAD;
TYPE=TABHEADING,IMAGE=pharmawf.gif,SIZE=(1.5 0.482143),$
-GOTO AFTERH;
-PDPHEAD
TYPE=TABHEADING,IMAGE=pdplogo1.gif,SIZE=(1.74675 0.5),$
-AFTERH
...
ENDSTYLE

I've tried but got no output, is there a way to do something like that?

Thanks.
 
Posts: 87 | Location: Montreal, QC, Canada | Registered: September 03, 2004Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
Hi

Hmmm I am surprised that doesnt work. Why dont you try using variables instead... like this..

-SET &MYSTYLE=IF &LOGO EQ 'PDP' THEN
-'TYPE=TABHEADING,IMAGE=pharmawf.gif,SIZE=(1.5 0.482143),$' ELSE 'TYPE=TABHEADING,IMAGE=pdplogo1.gif,SIZE=(1.74675 0.5),$';

ON TABLE SET STYLE *
&MYSTYLE
ENDSTYLE

Does that work?

Jodye
 
Posts: 163 | Registered: October 01, 2003Reply With QuoteEdit or Delete MessageReport This Post
Gold member
Posted Hide Post
That doesn't work. it's looking for a VALUE for the variable. You can't use a variable that contains a full line of the style sheet code but you can use variables for values ex: PAPER = &PAPERSIZE.

I had to make 2 different style sheets...
 
Posts: 87 | Location: Montreal, QC, Canada | Registered: September 03, 2004Reply With QuoteEdit or Delete MessageReport This Post
Gold member
Posted Hide Post
ON TABLE SET STYLE *
TYPE=TABHEADING,WHEN=&LOGO EQ 'PDP', IMAGE=pdplogo1.gif,SIZE=(1.74675 0.5),$
TYPE=TABHEADING,WHEN=&LOGO NE 'PDP', IMAGE=pharmawf.gif,SIZE=(1.5 0.482143),$
...
ENDSTYLE
 
Posts: 67 | Registered: April 15, 2004Reply With QuoteEdit or Delete MessageReport This Post
Member
Posted Hide Post
I try the following request,then it is no problem.
Dou you have SUBHEAD keyword, or IMAGE= keyword
is correnct?

-SET &LOGO='PXP';
TABLE FILE CAR
PRINT CAR MODEL SEATS
BY COUNTRY
ON TABLE SUBHEAD
" "
ON TABLE SET STYLE *
-IF &LOGO EQ 'PDP' THEN GOTO PDPHEAD;
TYPE=TABHEADING,IMAGE='http://www.accs.co.jp/accwe002.gif',
SIZE=(1.74675 0.5),$
-GOTO AFTERH;
-PDPHEAD
TYPE=TABHEADING,IMAGE='http://www.accs.co.jp/accwe017.gif',
SIZE=(1.5 0.482143),$
-AFTERH
ENDSTYLE
END
 
Posts: 6 | Location: osaka,japan | Registered: January 31, 2005Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
quote:
Originally posted by Stan:
[qb] ON TABLE SET STYLE *
TYPE=TABHEADING,WHEN=&LOGO EQ 'PDP',
<snip>[/qb]
Almost. After evalation of &LOGO, the WHEN condition needs to be a "literal vs. literal" comparison (of the string contained in &LOGO to the string "PDP"), so you need to single-quote &LOGO, thus:
...,WHEN='&LOGO' EQ 'PDP', ...,$

Without the tics, TABLE will see (perhaps):
...,WHEN=Vax EQ 'PDP',...,$
and will complain that there is no field named Vax.
 
Posts: 532 | Location: NYC | Registered: January 11, 2005Reply With QuoteEdit or Delete MessageReport This Post
Expert
Posted Hide Post
Flip, just to offer you encouragement, it is definitely possible to put dialog manager in style sheets. i do it all day long. Its a very useful technique, so i encourage you to tinker with it to get it to work, for future use. In this case, stan's and jack's when= is certainly the elegant way to go.
 
Posts: 2630 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
Yet another approach:


-DEFAULT &LOGO='???';
-*************************************
-SET &Gfile=DECODE &LOGO('PDP' 'accwe017.gif' ELSE 'accwe017.gif' );
-SET &Gsize=DECODE &LOGO('PDP' '(1.5 0.482143)' ELSE '(1.74675 0.5)' );
-*************************************

TABLE FILE yada
yada
ON TABLE SUBHEAD
" "
ON TABLE SET STYLE *
TYPE=TABHEADING,
IMAGE='http://www.accs.co.jp/&Gfile',SIZE=&Gsize,$
ENDSTYLE
END

This has the advantage of isolating the decision rules and magic constants up front (so they are apparent and maintainable), and avoids cluttering the TABLE code itself with IFs, WHENs, GOTOs or labels.

This message has been edited. Last edited by: <Mabel>,
 
Posts: 532 | Location: NYC | Registered: January 11, 2005Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
Looking back over the thread, I see that this was basically Jodye's idea.

If copying her code resulted in a "missing value" message (meaning an undefined dialog manager variable was referenced), the source is either &LOGO or &MYSTYLE. Two modifications to solve which ever problem:

a. include
-DEFAULT &LOGO=something
to ensure it is defined

b. a dash before each continuation line of the -SET:

-SET &MYSTYLE=IF &LOGO EQ 'PDP'
- THEN 'TYPE=TABHEADING,IMAGE=pharmawf.gif,SIZE=(1.5 0.482143),$'
- ELSE 'TYPE=TABHEADING,IMAGE=pdplogo1.gif,SIZE=(1.74675 0.5),$';

(the forum's rendering of long lines may have been misleading here)

With those changes, it should work.
 
Posts: 532 | Location: NYC | Registered: January 11, 2005Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
Thats exactly what I wrote, but yes it was mangled by the forum wrapping the text and I am sure it will work. Dialogue manager will let you store anything in a variable. We do that all the time.
 
Posts: 163 | Registered: October 01, 2003Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
Try This:


-SET &LOGO='PDP';

DEFINE FILE CAR
LOGO/A3 = '&LOGO';
END
TABLE FILE CAR
PRINT
'COMP.CAR'
'CARREC.MODEL'
'BODY.SEATS'
LOGO NOPRINT
BY
'ORIGIN.COUNTRY'
ON TABLE SUBHEAD
" "
ON TABLE NOTOTAL
ON TABLE SET STYLE *
UNITS=IN,
PAGESIZE='Letter',
LEFTMARGIN=0.250000,
RIGHTMARGIN=0.250000,
TOPMARGIN=0.250000,
BOTTOMMARGIN=0.250000,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
DEFMACRO=COND0001,
MACTYPE=RULE,
WHEN=N5 EQ 'PDP',
$
DEFMACRO=COND0002,
MACTYPE=RULE,
WHEN=N5 EQ 'PXP',
$
TYPE=REPORT,
GRID=OFF,
FONT='TIMES NEW ROMAN',
SIZE=10,
COLOR='BLACK',
BACKCOLOR='NONE',
STYLE=NORMAL,
$
TYPE=TABHEADING,MACRO=COND0001,IMAGE='http://www.accs.co.jp/accwe002.gif',
SIZE=(1.74675 0.5),
$
TYPE=TABHEADING,MACRO=COND0002,IMAGE='http://www.accs.co.jp/accwe017.gif',
SIZE=(1.5 0.482143),$
ENDSTYLE
END
Good Luck

This message has been edited. Last edited by: <Mabel>,
 
Posts: 610 | Location: Dallas, Texas | Registered: May 24, 2004Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    Can I put conditions (IF, tags) in a Style Sheet?

Copyright © 1996-2008 Information Builders, leaders in enterprise business intelligence.