Comments in ST editor

Introduction

You can use comments in your code to help others understand the intent of the program or function. Comments can be placed anywhere where a space character is allowed, except within character string literals. Comments have no impact on the execution of the program.

Single-line comments

Single line comments begin with a double slash // and end at the end of the line. In single-line comments, the special character combinations (* and *) or /* and */ have no special meaning like in multi-line comments.

Example

bFan := TRUE; // Turn on the fan

Single-line comments are supported by Control FPWIN Pro7 from version 7.6.0.0 onwards. They cause a compiler error in older Control FPWIN Pro7 versions.

Multi-line comments

Multi-line comments begin either with (* and end with *) or with /* and end with */. This type of comment can wrap over multiple lines. In multi-line comments, the special character combination // has no special meaning like in single-line comments.

Example 1

(* Calculate fan //speed// *)

Example 2

(*-------------------
* Calculate
fan speed *)

Example 3

/* Calculate fan //speed// */

Example 4

/*-------------------
* Calculate fan speed
*/
NOTE

Multi-line comments using slashes ("/*") are supported by Control FPWIN Pro7 from version 7.6.0.0 onwards. They cause a compiler error in older Control FPWIN Pro7 versions.

Nesting of multi-line comments

A nested comment is a comment inside another comment. Comments can be nested if the following option setting is enabled: Extras > Options > Compile options > Additional Errors > Nested multi-line comments.

With nested comments, you can quickly and easily comment out large blocks of code, even if the code already contains multi-line or single line comments.

Example 1

/* This is a multi-line comment
(* this is also a multi-line comment*) /*another multi-line comment*/
This is still part of the multi-line comment */

Example 2

(* Commented out code
/* Calculate fan speed */
bFan := TRUE; // Turn on the fan
*)

Incorrect comments

Example 1

(* wrong comment end characters */
/* wrong comment end characters *)

Example 2

/* Incorrect comment
/* /* This should be incorrect.
*/

Uniform Resource Locator (URL) within comments

URLs can be used within comments. Press <Ctrl> and click the URL text to open the URL in your default browser or email application.

Example

URL link

// sample comment https://www.google.com
// sample comment https://www.google.com/search?q=panasonic

email link

// sample comment mailto:email@example.com
// sample comment mailto:email@example.com?cc=secondemail@example.com,anotheremail@example.com,
&bcc=lastemail@example.com&subject=Mail%20from%20our%20Website

file link

// sample comment file://C:\filename.txt

folder link

// sample comment file://C:\foldername

FTP link

// sample comment ftp://username@192.168.178.55:8000
NOTE

Spaces in the URL must be replaced with %20.

Show auto-completion list within comments

If you want to insert a variable or instruction name into a comment, you can display the auto-completion list with the shortcut <Ctrl>+<Space>.

Related topics:

Modified on: 2023-10-06Feedback on this pagePanasonic hotline