Zeus Productions Banner

Home (Spotlight) | TOC | Products & Ordering | Technical Info | Contact Zeus


Zeus Tech Note
Using Comments

(This document last revised April 24, 1997)


Copyright © 1996-1997. Zeus Productions. All Rights Reserved.
Written by Bruce A. Epstein

Q. What is a comment and why do I care?


A. A comment is text within a program, script or batch file that is used to improve the readability for humans. Comments, as indicated by one or more special comment characters, are ignored by the compiler or interpreter. It is good practice to include liberal comments in your code, so that either you or someone else reading it later can make sense of it. It is not unusual to include a comment for every two to threee lines of programming, often referred to as self-documenting code.

Q. What is a comment character?

A. Comment characters are used to indicate that some text is a comment and should be ignored by the computer. Different languages and programs use different comment characters:

Creating Comments


Some languages only allow comments to exist on separate comment lines. Others, such as Lingo also allow comments to exist at the end of a line following actual programming scripts. In most languages anything following a comment character will be ignored until the next end-of-line character (usually a CR or CR/LF combination).

For example:

-- This is a Lingo comment on its own line

set x = 1 -- This is a Lingo comment at the end of a line

-- To create a multi-line comment in Lingo,
-- begin each line with it's own
-- comment delimiter

The C language allows comments to precede actual programming on the same line, as long as the comment starts with "/*" and ends with "*/ ". C uses two forward slashes "//" to comment out an entire line.

For example:
// This is a C comment that lasts until the end of the line

x = 1; /* This is a C comment at the end of a line */ 


/* This is a multi-line comment in C that lasts until
the ending comment-delimeter is reached,d, even if
it is not until a later line */


Although unusual, you could even do this:
/* This is a C comment at the start of a line */ x = 1; 

x = /* This is a C comment in the middle of a line */ 1; 

/* This is a /* nested C comment */ which will confuse some compilers */ 

Comments within Director

Director offers a number of ways to comment or uncomment your code. You can:

Continuation Characters


Most languages (the notable exception being C) assume that each line of code is terminated by and end-of-line character, usually a CR. A continuation character is a special character used to continue the current line of a script onto the next line. This is useful for breaking up long lines of code, especially for readability.

The Lingo continuation characters is created using Option-Return on the Mac or Alt-Enter on the PC. It looks like a line bent at a right angle (unfortunately, it does not reproduce in HTML or in most programs outside of Director.)

Beware of comments which end in a continuation character. They wull cause the next line to be included in the comment.

C does not use a continuation character. A line of code continues automatically until it is terminated by a semi-colon (;). The one exception is with macro definitions. A macro is assumed to terminate on the current line unless the backslash (\) continuation character is used.





Notes:





Home (Spotlight) | Table of Contents | Links | Contact Info

Place an Order | Products for Sale | Licensing | Downloads

TechNotes | FAQs | E-Mail Zeus | GuestBook | Glossary

[End of Page]

Copyright © 1996-1997. Zeus Productions. All Rights Reserved.