Reusing WebFOCUS StyleSheet Declarations With Macros

In this section:

If you frequently use a group of attributes within a StyleSheet declaration, you can create a StyleSheet macro that groups the sequence of attributes together, enabling you to apply them repeatedly throughout the StyleSheet without recoding them.

Defining a WebFOCUS StyleSheet Macro

How to:

A StyleSheet macro must be defined in the StyleSheet that references it and the macro definition must precede its use in the StyleSheet.

To define a macro, use the DEFMACRO attribute followed by the desired styling attributes.

Syntax: How to Define a WebFOCUS StyleSheet Macro

DEFMACRO = macroname, attribute1 = value1, [attribute2 = value2,]... $

where:

macroname
Is the name you assign to the macro you are creating.
attribute
Is any StyleSheet attribute, such as an attribute to format a report component, insert a graphic, define a hyperlink, or apply a condition for conditional formatting (WHEN).
value
Is the value you want to assign to the attribute.

Applying a WebFOCUS StyleSheet Macro

How to:

A StyleSheet macro applies all the formatting defined in the macro to the report component specified in the declaration. To apply a macro, use the MACRO attribute. You can apply one macro per declaration.

When applying a StyleSheet macro to a report component, you can override any attribute defined in the macro by specifying the same attribute with the new value in that declaration, following the MACRO attribute.

Syntax: How to Apply a WebFOCUS StyleSheet Macro

TYPE=type, [subtype,] MACRO=macroname, [condition,] $

where:

type

Is the report component you wish to affect. You can specify any report component.

subtype

Are any additional attributes, such as COLUMN, ACROSS, or ITEM, that are needed to identify the report component to which you are applying the macro. For information about how to specify different types of report components, see Identifying a Report Component in a WebFOCUS StyleSheet.

macroname

Is the name of the macro to apply to the specified report component. The macro must be defined in the same StyleSheet.

condition

Is an optional WHEN attribute that you can specify if you wish to make this declaration conditional. For information about conditional declarations, see Controlling Report Formatting.

Example: Defining, Applying, and Overriding a WebFOCUS StyleSheet Macro

The following annotated example illustrates how to define, apply, and override macros in your StyleSheet:

   TABLE FILE GGSALES
    SUM UNITS DOLLARS
    BY CATEGORY BY PRODUCT
    HEADING
    "Sales Report"
    FOOTING
    "Sales Report - Page <TABPAGENO"
    ON TABLE SET STYLE *
    TYPE=REPORT, GRID=OFF,$ 
1.  DEFMACRO=A, STYLE=BOLD, SIZE=12, $
2.  DEFMACRO=BI, STYLE=BOLD+ITALIC, COLOR=PURPLE, $
3.  TYPE=HEADING, MACRO=A, $
4.  TYPE=FOOTING, MACRO=BI, COLOR=BLACK, $
5.  TYPE=DATA, COLUMN=N1, MACRO=BI, $ 
   ENDSTYLE
   END
  1. Defines the A macro.
  2. Defines the BI macro.
  3. Illustrates how the A macro is applied to the heading.
  4. Illustrates how the BI macro is applied to the footing and is partially overridden by the attribute value pair COLOR=BLACK.
  5. Illustrates how the BI macro is applied to the data in the BY sort field CATEGORY (specified by TYPE=DATA, COLUMN=N1).

The output is: