Skip to main content

Message Pragmas

Message pragmas force the display of messages in the message view during the compile process.

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

Table 22. 4 types of message pragmas

Pragma

Message type

{text <'text string'>}

Text

Output of the text <text string>

{info <'info string'>}

_cds_icon_info.png: Information

Output of the information <infostring>

{warning <'warning string'>}

_cds_icon_warning.png: Warning:

Output of the warning <warning string>

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

Important

The Warning pragma  {warning <'warning string'>} is allowed only for objects such as POUs, for statements, and for variables.

Example 252. Usage for variables
POGRAM PLC_PRG
VAR               
 {warning <'warning message'>}
  var1 : INT;      
END_VAR



{error <'error string'>}

_cds_icon_error.png: Error

Output of the error <errorstring>



Tip

In the CODESYS messages view, you can use the Next Message and Previous Message commands to jump from one message in the Information, Warning, or Error category to the source position of the message. This means you jump to the position where the pragma is added in the source code.

Example 253.
VAR
    ivar : INT; {info 'TODO: should get another name'}
    bvar : BOOL;
    arrTest : ARRAY [0..10] OF INT;
    i:INT;
END_VAR
arrTest[i] := arrTest[i]+1;
ivar:=ivar+1;

{warning 'This is a warning'}
{text 'Part xy has been compiled completely'}

Display in the message view:

_cds_img_pragma_message.png