Developer Documentation Library > Scripting > mrScriptBasic overview > mrScriptBasic language reference > General information > Comments and coding conventions
Comments and coding conventions
This section presents information on the mechanics of writing code, including breaking and combining lines of code and adding comments to your code.
Breaking a single statement into multiple lines
A long statement can be broken into multiple lines using the line-continuation character (a space followed by an underscore). Using this character can make your code easier to read, both online and when printed. The following code is broken into three lines with _ (line-continuation characters, that is, underscores):
TotalDrinks = _
SpontDrinks + _
You can't follow a line-continuation character with any other character (not even a space character or a comment) on the same line. There are also some restrictions on where you can break lines. For example, you cannot break a line in the middle of an argument or keyword. However, you can break an argument list, provided the individual arguments are intact.
Combining statements on one line
Unlike VBScript, in mrScriptBasic it is not possible to combine multiple statements on a single line. Similarly, you cannot combine a GoTo label and a statement on one line. Combining statements on a single line is not supported because it can cause problems for GUI tools that use mrScriptBasic.
String literals
Single-line string literals must be enclosed in double quotation marks and can contain single quotation marks. To include a double quotation mark in a string literal, insert two double quotation marks. For example:
sIntroduction = "Click ""Yes"" to begin"
Multiline string literals
You define a multiline string literal by enclosing it within "! and !" characters, as shown in the following example:
sIntroduction = "!
Welcome to the ACME annual survey
Click OK to start
Click Cancel to end
"! must be followed by a new line and !" must be preceded by a new line.
You can include double quotation marks and exclamation points in the string literal. For example:
sIntroduction = "!
Welcome to the ACME annual survey
Click "Yes!" to begin!
Use the preceding method to define a string literal only if you want newline characters within the value of the string. If you want to define a string literal over multiple lines only because you want to make your script easier to read, you should use the backslash (\) character. For example:
sIntroduction = "Welcome to the annual ACME survey \
on purchasing preferences among \
the 18 to 30 age group"
When you execute your script, the value of this string will be exactly the same as if you had defined it as a single-line string literal without the two backslash characters.
Adding comments to code
Use the comment symbol (') to put remarks in your script code to make it easier to understand. For example:
' Check whether the respondent is under 20
If age < 20 Then     ' Age must not be less than 20
  age = 20           ' if necessary we force it
                     ' to be 20
End If
Comments can follow a statement on the same line or can occupy an entire line. Both are illustrated in the preceding example. Comments cannot follow a line-continuation character on the same line.
In addition to the standard VBScript comments, block comments can be used in mrScriptBasic. Block comments are denoted by using '! (block comment start characters) and !' (block comment end characters). For example:
'! Clean the age data. First check
whether the age is less than 20, and if it is,
set it to 20 !'
If age < 20 Then
  age = 20
End If
See also
General information