Skip to main content

Message Pragmas

Message pragmas generate output texts which are displayed in the Messages view after a compile operation. In addition, a message type (Message, Warning, or Error ) can be assigned.

Insertion location: Separate or existing line in the text editor of a POU.

Table 23. Four types of message pragmas

Syntax of Message Pragma

Example of Code Fragment

Description

{text <literal> }

{text 'Hallo Allgäu!'}
{text 'Part PLC_PRG has been compiled completely'}

No type

Output; defined in string literal <literal>:

Hallo Allgäu!

Part PLC_PRG has been compiled completely

{info <literal> }

{info 'I01: This is for your information.' }

Typed as a message _cds_icon_info.png

Output:

_cds_icon_info.png I01:This is for your information.

{warning <literal>}

{warning 'W01: This is a warning to you.'}

Typed as a warning _cds_icon_warning.png

Unlike the attribute pragma 'obsolete', you define this kind of warning locally for the current position.

Important

The {warning} message pragma is allowed only for objects such as POUs, for statements, and for variables.

Output:

_cds_icon_warning.png C0373: W01: This is a warning to you.

{error <literal>}

{error 'E00: Error has occured.'}

Typed as an error _cds_icon_error.png

Output:

_cds_icon_error.png E00: Error has occurred.



Tip

In the Messages view, the _cds_icon_error.png Error, _cds_icon_warning.png Warning(s), and _cds_icon_info.png Message(s) buttons are available to filter the output texts. Or you can use the Next Message and Previous Message commands to navigate through the individual messages.

Note the Go To Source Position command. You can use this command to jump to the position where the pragma is implemented in the source code.

Example 253. Example
PROGRAM PLC_PRG
VAR
    iVar : INT; {info 'Info0: This is for your information.'}
    bVar : BOOL;
    arrTest : ARRAY [0..10] OF INT;
END_VAR
{text 'Hello Allgäu!'}

arrTest[iVar] := arrTest[iVar]+1;
{warning 'W01: This is a warning'}
iVar := iVar+1;
{warning 'W02: This is a second warning'}

{text 'Part PLC_PRG has been compiled completely'}

Display in the message view:

_cds_img_pragma_message.png