Message pragmas

Message pragmas are used to force the output of messages in the message window during the compilation process.

The pragma instruction can be inserted in a separate or an existing line in the text editor of a POU.

Types

Pragma

Message type

{text <'textstring'>}

Text: Output of <text string>.

{info <'textstring'>}

Message pragmas 1: Information: Output of <text string>.

{warning <'textstring'>}

Message pragmas 2: Warning: Output of <text string>.

In contrast to the attribute pragma 'obsolete', you define the warning locally for the current position.

{error <'textstring'>}

Message pragmas 3: Error: Output of <text string>.

Message pragmas 4:

In the TwinCAT message window, you can access the source position of a message of category Information, Warning and Error by using the commands Next Message or Previous Message. This means you get to the position where the pragma is added in the source code.

Example:

VAR 
    nVar : INT; {info 'TODO: should get another name'} 
    bVar : BOOL; 
    aTest : ARRAY [0..10] OF INT; 
    nIdx : INT; 
END_VAR 

aTest[nIdx] := aTest[nIdx]+1; 
nVar := nVar+1; 

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

Output in the message window:

Message pragmas 5:

See also: