Conditional Formatting

Message formatting can also be configured to apply only in certain conditions. This allows you to specialize the message display, for example according to the message level. You can enter a conditional statement in the format:

%?<condition> %(<true condition> [%:<false condition>] %)

The false branch is optional and, if it is not supplied, nothing is displayed. The condition field consists of a letter, and optionally, a conditional operator and value.

The following conditional variables can hold any legitimate value, and must be tested using a relational operator:

c

Column number

g

Message level

l

Line number

n

Message number

S

Suppression Type

u

Context message depth

Y

Severity level

The possible values for Message Level (%g) are:

0

Information

1

Warning

2

Error

3

User Message

For example, to display Err for Level 2 messages and Msg for all others, the conditional statement would look like:

%?g==2%(Err%:Msg%)

Primary messages have a context message depth (u) of zero, and context messages are level 1 or greater. Typical conditional processing of context messages is:

%?u==0%(primary message %: context message %)
These Message Levels are not to be confused with the RCF (Rule Configuration File) Message Levels documented in the Helix QAC for C and Helix QAC for C++component manuals, nor with the Severity levels documented in Viewing and Filtering the Diagnostics.

The following conditional variables can only be tested for a change in their values:

C

File name, line and column number

F

File name

L

File name and line number

For example, a simple check for a file name is:

%?F%(\n%f%)

In this example, if the file name has changed (F), the new file name will be displayed on a new line (\n%f). The conditional variable C can be used to determine the positioning of the warning location caret (^). In the default message format, the caret is omitted for messages with the same location as the previous message. To replicate this, use the following conditional statement:

%?C%(%^%)

This statement will compare the file name, line, and column number (C) of the current message with the previous message. If the location is different, the statement is considered True and the caret is displayed, followed by a new line, which is added implicitly.

Finally, properties of a message can be queried with the following Boolean conditional variables:

h

Is message a hard error (level 9)

j

Are suppressions present?

v

Is verbose text present?

For example, the following statement:

%t%?v%(\n%v%) will print the message text (%t) followed by the verbose text on a new line (\n%v), if it exists (%?v).

The %j conditional will only be triggered when the suppression message is not empty.