Skip to main content

ST Comments

Comment

Description

Example

Single-line

There are two ways of marking:

  • Starts with // and ends at the end of the line

  • Starts with /// and ends at the end of the line

In CODESYS, these comments are handled the same way.

However, if library documentation is created using the LibDoc Scripting Collection, the following applies:

  • When the property LibDocContent = DocsOnly is entered in the project information, only comments marked with /// are processed into library documentation. See the example for this below the table.

  • When LibDocContent = CommentsAndDocs (default setting) is defined, all comments are processed into library documentation.

/// This is a comment

/// This is a comment

Multiline

Starts with (* and ends with *).

(* This is a multiline comment *)

Nested

Starts with (* and ends with *). Additional comments (*....*) can be contained within this comment.

( * a:=inst.out; (* comment 1 *) b:=b+1; (* comment 2 *) *)

The comments are displayed as information on a variable in the comment column of the variable declaration in online mode, as well as in the tooltip when the mouse pointer is positioned over a variable. The following logic and prioritization apply:

  1. When a comment beginning with /// is before the variable, this comment is displayed.

  2. When a comment beginning with // or within (**) is after the variable declaration in the same line, this comment is displayed

  3. When a comment beginning with // or within (**) is before the variable declaration in the same line, this comment is displayed

If a comment cannot be displayed in full in online mode due to its length, then the _cds_icon_comment_more_lines.png symbol is displayed in this comment field. When the cursor is then positioned over this symbol, the complete comment is displayed in the tooltip.

Example 79. Comments for tooltips and POU documentation
A tooltip in the header of a POU is defined by the following comment:
    // tooltip text – line 1
    // tooltip text – line 2
    // tooltip text – line 3

    Afterwards the documentation is defined as follows:
    /// reStructuredText


Note: The different comment types can be used to control which comments should be displayed in the documentation of a library and which comments are intended only for library developers.