Product SiteDocumentation Site

1.10.3. Comments

A comment is a sequence of characters delimited by specific characters. It is ignored by the program but acts as a separator. For example, a token containing one comment is treated as two tokens.
The interpreter recognizes the following types of comments:
A line comment is started by two subsequent minus signs (--) and ends at the end of a line. Example:
"Fred"
"Don't Panic!"
'You shouldn''t'        -- Same as "You shouldn't"
""
In this example, the language processor processes the statements from 'Fred' to 'You shouldn''t', ignores the words following the line comment, and continues to process the statement "".
A standard comment is a sequence of characters (on one or more lines) delimited by /* and */. Within these delimiters any characters are allowed. Standard comments can contain other standard comments, as long as each begins and ends with the necessary delimiters. They are called nested comments. Standard comments can be anywhere and of any length.
/* This is an example of a valid Rexx comment */
Take special care when commenting out lines of code containing /* or */ as part of a literal string. Consider the following program segment:

Example 1.2. Comments

01    parse pull input
02    if substr(input,1,5) = "/*123"
03      then call process
04    dept = substr(input,32,5)
To comment out lines 2 and 3, the following change would be incorrect:
01    parse pull input
02 /* if substr(input,1,5) = "/*123"
03      then call process
04 */ dept = substr(input,32,5)

This is incorrect because the language processor would interpret the /* that is part of the literal string /*123 as the start of a nested standard comment. It would not process the rest of the program because it would be looking for a matching standard comment end (*/).
You can avoid this type of problem by using concatenation for literal strings containing /* or */; line 2 would be:
if substr(input,1,5) = "/" || "*123"
You could comment out lines 2 and 3 correctly as follows:

Example 1.3. Comments

01    parse pull input
02 /* if substr(input,1,5) = "/" || "*123"
03      then call process
04 */ dept = substr(input,32,5)

Both types of comments can be mixed and nested. However, when you nest the two types, the type of comment that comes first takes precedence over the one nested. Here is an example:

Example 1.4. Comments

"Fred"
"Don't Panic!"
'You shouldn''t'        /* Same as "You shouldn't"
""                      -- The null string         */

In this example, the language processor ignores everything after 'You shouldn''t' up to the end of the last line. In this case, the standard comment has precedence over the line comment.
When nesting the two comment types, make sure that the start delimiter of the standard comment /* is not in the line commented out with the line comment signs.

Example 1.5. Comments

"Fred"
"Don't Panic!"
'You shouldn''t'        -- Same as /* "You shouldn't"
""                      The null string         */

This example produces an error because the language processor ignores the start delimiter of the standard comment, which is commented out using the line comment.