User Tools

Site Tools


Comments

Comments can be used to provide clarification of intent, make note of a particular position in the code that you want to come back to, prevent the interpreter from reading a portion of the code (e.g. debugging), or whatever other purpose you might think of. The underlying principal being, a comment is used to tell the interpreter to ignore something. Whether that something is simply text, or syntax, matters not.

DAZ Script supports two different styles of comments. One being a pair of slashes (//) followed by whatever is being commented. And the other being whatever is being commented, enclosed between an opposing pair of characters, each consisting of a slash and an asterisk (/* and */).

The double slash (//) style is used for single-line comments. The comment begins at the double slash and continues until the end of the line.

The slash/asterisk pair (/**/) style is used for multi-line comments, or in-line comments. The comment begins with the leading slash/asterisk, and continues until the opposite asterisk/slash. The double slash style can exist within the slash/asterisk pair, so it is recommended that the double slash style be used for general notes, and the slash/asterisk pair be used for debugging purposes, although it is entirely up to you to decide how you prefer to use them.

Examples

An example of valid comments.

// A single-line comment.
var nLimit = 5;// A single-line comment.
 
/* A multi-line comment
 
// This for loop is suspect for causing a problem.
// We take it out of the equation while investigating said problem.
 
for( var i = 0; i < nLimit; i++ ){
	// ...statements
}
*/
 
// Below is an in-line comment.
// Notice that the semi-colon is outside the comment...
// ...making this a valid statement for an undefined variable declaration
var sTmp/* = "Temp"*/;

An example of invalid comments. This produces an error, which is caused by attempting to nest the slash/asterisk pair style.

/* A multi-line comment.
 
// This for loop is suspect for causing a problem.
// We take it out of the equation while investigating said problem.
 
/*This in-line comment will cause an error in the interpreter, because the following lines are interpreted as code.*/
 
// Notice that this loop is no longer commented...
for( var i = 0; i < nLimit; i++ ){
	// ...statements
}
*/ //<-- Notice this is no longer part of the comment.